Compare commits
2
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
fce24cdb5e | ||
|
|
a54a952cef |
@@ -17,22 +17,6 @@
|
||||
*/tclsh*
|
||||
*/tcltest*
|
||||
*/versions.vc
|
||||
libtommath/bn.ilg
|
||||
libtommath/bn.ind
|
||||
libtommath/pretty.build
|
||||
libtommath/tommath.src
|
||||
libtommath/*.pdf
|
||||
libtommath/*.pl
|
||||
libtommath/*.sh
|
||||
libtommath/tombc/*
|
||||
libtommath/pre_gen/*
|
||||
libtommath/pics/*
|
||||
libtommath/mtest/*
|
||||
libtommath/logs/*
|
||||
libtommath/etc/*
|
||||
libtommath/demo/*
|
||||
libtommath/*.out
|
||||
libtommath/*.tex
|
||||
unix/autoMkindex.tcl
|
||||
unix/dltest.marker
|
||||
unix/tcl.pc
|
||||
|
||||
+1
-1
@@ -414,7 +414,7 @@
|
||||
Tcl_IsChannelExisting, and Tcl_ClearChannelHandlers to conform to the
|
||||
new stacked channel implementation. Their stub slots were also moved
|
||||
to give preference to the new 8.3.2 stub functions. This will cause an
|
||||
incompatibility with 8.4a1 only.
|
||||
incompatability with 8.4a1 only.
|
||||
(StopCopy): fixed a bug introduced by a partial fix in 8.3.2 that
|
||||
didn't set nonBlocking correctly when resetting the flags for the
|
||||
write side. [Bug: 6261]
|
||||
|
||||
+3
-3
@@ -847,7 +847,7 @@
|
||||
exit.
|
||||
|
||||
* tests/exec.test: marked exec-18.1 unixOnly until the Windows
|
||||
incompatibility (in the test, not the core) can be resolved.
|
||||
incompatability (in the test, not the core) can be resolved.
|
||||
|
||||
* tests/http.test (http-3.11): added close $fp that was causing an
|
||||
error on Windows because the file was not closed before deleting.
|
||||
@@ -3642,7 +3642,7 @@
|
||||
* compat/strtoll.c (strtoll):
|
||||
* compat/strtoull.c (strtoull):
|
||||
* unix/tclUnixPort.h:
|
||||
* win/tclWinPort.h: Const-ing 64-bit compatibility declarations. Note
|
||||
* win/tclWinPort.h: Const-ing 64-bit compatability declarations. Note
|
||||
that the return pointer is non-const because it is entirely legal for
|
||||
the functions to be called from somewhere that owns the string being
|
||||
passed. Fixes problem reported by Larry Virden.
|
||||
@@ -3779,7 +3779,7 @@
|
||||
|
||||
There are a lot of changes from this TIP, so please see
|
||||
http://purl.org/tcl/tip/72.html for discussion of
|
||||
backward-compatibility issues, but the main ones modifications are in:
|
||||
backward-compatability issues, but the main ones modifications are in:
|
||||
|
||||
* generic/tcl.h: New types.
|
||||
* generic/tcl.decls: New public functions.
|
||||
|
||||
+2
-2
@@ -947,7 +947,7 @@
|
||||
declarations match and will end up using the declarations in the
|
||||
public code from now on because of #include ordering. Keeping the old
|
||||
declarations in tclInt.decls; there's no need to gratuitously break
|
||||
compatibility for those extensions which are already clients of the
|
||||
compatability for those extensions which are already clients of the
|
||||
namespace code.
|
||||
|
||||
2003-08-23 Zoran Vasiljevic <zoran@archiwrae.com>
|
||||
@@ -1278,7 +1278,7 @@
|
||||
|
||||
* generic/tclVar.c (Tcl_ArrayObjCmd, TclArraySet): Made [array get]
|
||||
and [array set] work with dictionaries, producing them and consuming
|
||||
them. Note that for compatibility reasons, you will never get a dict
|
||||
them. Note that for compatability reasons, you will never get a dict
|
||||
from feeding a string literal to [array set] since that alters the
|
||||
trace behaviour of "multi-key" sets. [Bug 759935]
|
||||
|
||||
|
||||
+1
-1
@@ -1356,7 +1356,7 @@
|
||||
2004-10-07 Donal K. Fellows <donal.k.fellows@man.ac.uk>
|
||||
|
||||
* *.3: Convert CONST to const and VOID to void so we document how
|
||||
people should actually use the Tcl API and not the compatibility hacks
|
||||
people should actually use the Tcl API and not the compatability hacks
|
||||
that it has to have.
|
||||
|
||||
* doc/man.macros, *.3: Update .AS macro so it can know how wide to
|
||||
|
||||
+1
-1
@@ -106,5 +106,5 @@ closedir(
|
||||
close(dirp->dd_fd);
|
||||
dirp->dd_fd = -1;
|
||||
dirp->dd_loc = 0;
|
||||
ckfree(dirp);
|
||||
ckfree((char *) dirp);
|
||||
}
|
||||
|
||||
+1
-1
@@ -100,7 +100,7 @@ waitpid(
|
||||
} else {
|
||||
prevPtr->nextPtr = waitPtr->nextPtr;
|
||||
}
|
||||
ckfree(waitPtr);
|
||||
ckfree((char *) waitPtr);
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
+8
-23
@@ -51,42 +51,27 @@ in the interpreter's result, and nothing is stored at *\fIintPtr\fR
|
||||
or *\fIdoublePtr\fR or *\fIboolPtr\fR.
|
||||
.PP
|
||||
\fBTcl_GetInt\fR expects \fIsrc\fR to consist of a collection
|
||||
of integer digits, optionally signed and optionally preceded and
|
||||
followed by white space. If the first two characters of \fIsrc\fR
|
||||
of integer digits, optionally signed and optionally preceded by
|
||||
white space. If the first two characters of \fIsrc\fR
|
||||
after the optional white space and sign are
|
||||
.QW \fB0x\fR
|
||||
.QW 0x
|
||||
then \fIsrc\fR is expected to be in hexadecimal form; otherwise,
|
||||
if the first such characters are
|
||||
.QW \fB0o\fR
|
||||
then \fIsrc\fR is expected to be in octal form; otherwise,
|
||||
if the first such characters are
|
||||
.QW \fB0b\fR
|
||||
then \fIsrc\fR is expected to be in binary form; otherwise,
|
||||
if the first such character is
|
||||
.QW \fB0\fR
|
||||
.QW 0
|
||||
then \fIsrc\fR
|
||||
is expected to be in octal form; otherwise, \fIsrc\fR is
|
||||
expected to be in decimal form.
|
||||
.PP
|
||||
\fBTcl_GetDouble\fR expects \fIsrc\fR to consist of a floating-point
|
||||
number, which is: white space; a sign; a sequence of digits; a
|
||||
decimal point
|
||||
.QW \fB.\fR ;
|
||||
a sequence of digits; the letter
|
||||
.QW \fBe\fR ;
|
||||
decimal point; a sequence of digits; the letter
|
||||
.QW e ;
|
||||
a signed decimal exponent; and more white space.
|
||||
Any of the fields may be omitted, except that
|
||||
the digits either before or after the decimal point must be present
|
||||
and if the
|
||||
.QW \fBe\fR
|
||||
is present then it must be followed by the exponent number. If there
|
||||
are no fields apart from the sign and initial sequence of digits
|
||||
(i.e., no decimal point or exponent indicator), that
|
||||
initial sequence of digits should take one of the forms that
|
||||
\fBTcl_GetInt\fR supports, described above. The use of
|
||||
.QW \fB,\fR
|
||||
as a decimal point is not supported nor should any other sort of
|
||||
inter-digit separator be present.
|
||||
.QW e
|
||||
is present then it must be followed by the exponent number.
|
||||
.PP
|
||||
\fBTcl_GetBoolean\fR expects \fIsrc\fR to specify a boolean
|
||||
value. If \fIsrc\fR is any of \fB0\fR, \fBfalse\fR,
|
||||
|
||||
+3
-3
@@ -23,11 +23,11 @@ Tcl interpreter handle.
|
||||
A version string consisting of one or more decimal numbers
|
||||
separated by dots.
|
||||
.AP int exact in
|
||||
1 means that only the particular version specified by
|
||||
Non-zero means that only the particular version specified by
|
||||
\fIversion\fR is acceptable.
|
||||
0 means that versions newer than \fIversion\fR are also
|
||||
Zero means that versions newer than \fIversion\fR are also
|
||||
acceptable as long as they have the same major version number
|
||||
as \fIversion\fR. Other bits have no effect.
|
||||
as \fIversion\fR.
|
||||
.BE
|
||||
.SH INTRODUCTION
|
||||
.PP
|
||||
|
||||
@@ -20,7 +20,6 @@ This command joins each of its arguments together with spaces after
|
||||
trimming leading and trailing white-space from each of them. If all of the
|
||||
arguments are lists, this has the same effect as concatenating them
|
||||
into a single list.
|
||||
Arguments that are empty (after trimming) are ignored entirely.
|
||||
It permits any number of arguments;
|
||||
if no \fIarg\fRs are supplied, the result is an empty string.
|
||||
.SH EXAMPLES
|
||||
|
||||
+214
-171
@@ -17,14 +17,14 @@ expr \- Evaluate an expression
|
||||
.BE
|
||||
.SH DESCRIPTION
|
||||
.PP
|
||||
Concatenates \fIarg\fRs, separated by a space, into an expression, and evaluates
|
||||
that expression, returning its value.
|
||||
The operators permitted in an expression include a subset of
|
||||
Concatenates \fIarg\fRs (adding separator spaces between them),
|
||||
evaluates the result as a Tcl expression, and returns the value.
|
||||
The operators permitted in Tcl expressions include a subset of
|
||||
the operators permitted in C expressions. For those operators
|
||||
common to both Tcl and C, Tcl applies the same meaning and precedence
|
||||
as the corresponding C operators.
|
||||
The value of an expression is often a numeric result, either an integer or a
|
||||
floating-point value, but may also be a non-numeric value.
|
||||
Expressions almost always yield numeric results
|
||||
(integer or floating-point values).
|
||||
For example, the expression
|
||||
.PP
|
||||
.CS
|
||||
@@ -32,68 +32,78 @@ For example, the expression
|
||||
.CE
|
||||
.PP
|
||||
evaluates to 14.2.
|
||||
Expressions differ from C expressions in the way that
|
||||
operands are specified. Expressions also support
|
||||
non-numeric operands, string comparisons, and some
|
||||
Tcl expressions differ from C expressions in the way that
|
||||
operands are specified. Also, Tcl expressions support
|
||||
non-numeric operands and string comparisons, as well as some
|
||||
additional operators not found in C.
|
||||
.PP
|
||||
When an expression evaluates to an integer, the value is the decimal form of
|
||||
the integer, and when an expression evaluates to a floating-point number, the
|
||||
value is the form produced by the \fB%g\fR format specifier of Tcl's
|
||||
\fBformat\fR command.
|
||||
.SS OPERANDS
|
||||
.PP
|
||||
An expression consists of a combination of operands, operators, parentheses and
|
||||
commas, possibly with whitespace between any of these elements, which is
|
||||
ignored.
|
||||
An integer operand may be specified in decimal, binary
|
||||
(the first two characters are \fB0b\fR), octal
|
||||
(the first two characters are \fB0o\fR), or hexadecimal
|
||||
(the first two characters are \fB0x\fR) form. For
|
||||
compatibility with older Tcl releases, an operand that begins with \fB0\fR is
|
||||
interpreted as an octal integer even if the second character is not \fBo\fR.
|
||||
A floating-point number may be specified in any of several
|
||||
common decimal formats, and may use the decimal point \fB.\fR,
|
||||
\fBe\fR or \fBE\fR for scientific notation, and
|
||||
the sign characters \fB+\fR and \fB\-\fR. The
|
||||
following are all valid floating-point numbers: 2.1, 3., 6e4, 7.91e+16.
|
||||
The strings \fBInf\fR
|
||||
and \fBNaN\fR, in any combination of case, are also recognized as floating point
|
||||
values. An operand that doesn't have a numeric interpretation must be quoted
|
||||
with either braces or with double quotes.
|
||||
A Tcl expression consists of a combination of operands, operators,
|
||||
parentheses and commas.
|
||||
White space may be used between the operands and operators and
|
||||
parentheses (or commas); it is ignored by the expression's instructions.
|
||||
Where possible, operands are interpreted as integer values.
|
||||
Integer values may be specified in decimal (the normal case), in binary
|
||||
(if the first two characters of the operand are \fB0b\fR), in octal
|
||||
(if the first two characters of the operand are \fB0o\fR), or in hexadecimal
|
||||
(if the first two characters of the operand are \fB0x\fR). For
|
||||
compatibility with older Tcl releases, an octal integer value is also
|
||||
indicated simply when the first character of the operand is \fB0\fR,
|
||||
whether or not the second character is also \fBo\fR.
|
||||
If an operand does not have one of the integer formats given
|
||||
above, then it is treated as a floating-point number if that is
|
||||
possible. Floating-point numbers may be specified in any of several
|
||||
common formats making use of the decimal digits, the decimal point \fB.\fR,
|
||||
the characters \fBe\fR or \fBE\fR indicating scientific notation, and
|
||||
the sign characters \fB+\fR or \fB\-\fR. For example, all of the
|
||||
following are valid floating-point numbers: 2.1, 3., 6e4, 7.91e+16.
|
||||
Also recognized as floating point values are the strings \fBInf\fR
|
||||
and \fBNaN\fR making use of any case for each character.
|
||||
If no numeric interpretation is possible (note that all literal
|
||||
operands that are not numeric or boolean must be quoted with either
|
||||
braces or with double quotes), then an operand is left as a string
|
||||
(and only a limited set of operators may be applied to it).
|
||||
.PP
|
||||
An operand may be specified in any of the following ways:
|
||||
Operands may be specified in any of the following ways:
|
||||
.IP [1]
|
||||
As a numeric value, either integer or floating-point.
|
||||
.IP [2]
|
||||
As a boolean value, using any form understood by \fBstring is\fR
|
||||
\fBboolean\fR.
|
||||
.IP [3]
|
||||
As a variable, using standard \fB$\fR notation.
|
||||
The value of the variable is then the value of the operand.
|
||||
As a Tcl variable, using standard \fB$\fR notation.
|
||||
The variable's value will be used as the operand.
|
||||
.IP [4]
|
||||
As a string enclosed in double-quotes.
|
||||
Backslash, variable, and command substitution are performed as described in
|
||||
\fBTcl\fR.
|
||||
The expression parser will perform backslash, variable, and
|
||||
command substitutions on the information between the quotes,
|
||||
and use the resulting value as the operand
|
||||
.IP [5]
|
||||
As a string enclosed in braces.
|
||||
The operand is treated as a braced value as described in \fBTcl\fR.
|
||||
The characters between the open brace and matching close brace
|
||||
will be used as the operand without any substitutions.
|
||||
.IP [6]
|
||||
As a Tcl command enclosed in brackets.
|
||||
Command substitution is performed as described in \fBTcl\fR.
|
||||
The command will be executed and its result will be used as
|
||||
the operand.
|
||||
.IP [7]
|
||||
As a mathematical function such as \fBsin($x)\fR, whose arguments have any of the above
|
||||
forms for operands. See \fBMATH FUNCTIONS\fR below for
|
||||
As a mathematical function whose arguments have any of the above
|
||||
forms for operands, such as \fBsin($x)\fR. See \fBMATH FUNCTIONS\fR below for
|
||||
a discussion of how mathematical functions are handled.
|
||||
.PP
|
||||
Because \fBexpr\fR parses and performs substitutions on values that have
|
||||
already been parsed and substituted by \fBTcl\fR, it is usually best to enclose
|
||||
expressions in braces to avoid the first round of substitutions by
|
||||
\fBTcl\fR.
|
||||
Where the above substitutions occur (e.g. inside quoted strings), they
|
||||
are performed by the expression's instructions.
|
||||
However, the command parser may already have performed one round of
|
||||
substitution before the expression processor was called.
|
||||
As discussed below, it is usually best to enclose expressions
|
||||
in braces to prevent the command parser from performing substitutions
|
||||
on the contents.
|
||||
.PP
|
||||
Below are some examples of simple expressions where the value of \fBa\fR is 3
|
||||
and the value of \fBb\fR is 6. The command on the left side of each line
|
||||
produces the value on the right side.
|
||||
For some examples of simple expressions, suppose the variable
|
||||
\fBa\fR has the value 3 and
|
||||
the variable \fBb\fR has the value 6.
|
||||
Then the command on the left side of each of the lines below
|
||||
will produce the value on the right side of the line:
|
||||
.PP
|
||||
.CS
|
||||
.ta 6c
|
||||
@@ -104,41 +114,34 @@ produces the value on the right side.
|
||||
.CE
|
||||
.SS OPERATORS
|
||||
.PP
|
||||
For operators having both a numeric mode and a string mode, the numeric mode is
|
||||
chosen when all operands have a numeric interpretation. The integer
|
||||
interpretation of an operand is preferred over the floating-point
|
||||
interpretation. To ensure string operations on arbitrary values it is generally a
|
||||
good idea to use \fBeq\fR, \fBne\fR, or the \fBstring\fR command instead of
|
||||
more versatile operators such as \fB==\fR.
|
||||
.PP
|
||||
Unless otherwise specified, operators accept non-numeric operands. The value
|
||||
of a boolean operation is 1 if true, 0 otherwise. See also \fBstring is\fR
|
||||
\fBboolean\fR. The valid operators, most of which are also available as
|
||||
commands in the \fBtcl::mathop\fR namespace (see \fBmathop\fR(n)), are listed
|
||||
below, grouped in decreasing order of precedence:
|
||||
The valid operators (most of which are also available as commands in
|
||||
the \fBtcl::mathop\fR namespace; see the \fBmathop\fR(n) manual page
|
||||
for details) are listed below, grouped in decreasing order of precedence:
|
||||
.TP 20
|
||||
\fB\-\0\0+\0\0~\0\0!\fR
|
||||
.
|
||||
Unary minus, unary plus, bit-wise NOT, logical NOT. These operators
|
||||
may only be applied to numeric operands, and bit-wise NOT may only be
|
||||
applied to integers.
|
||||
Unary minus, unary plus, bit-wise NOT, logical NOT. None of these operators
|
||||
may be applied to string operands, and bit-wise NOT may be
|
||||
applied only to integers.
|
||||
.TP 20
|
||||
\fB**\fR
|
||||
.
|
||||
Exponentiation. Valid for numeric operands.
|
||||
Exponentiation. Valid for any numeric operands.
|
||||
.TP 20
|
||||
\fB*\0\0/\0\0%\fR
|
||||
.
|
||||
Multiply and divide, which are valid for numeric operands, and remainder, which
|
||||
is valid for integers. The remainder, an absolute value smaller than the
|
||||
absolute value of the divisor, has the same sign as the divisor.
|
||||
Multiply, divide, remainder. None of these operators may be
|
||||
applied to string operands, and remainder may be applied only
|
||||
to integers.
|
||||
The remainder will always have the same sign as the divisor and
|
||||
an absolute value smaller than the absolute value of the divisor.
|
||||
.RS
|
||||
.PP
|
||||
When applied to integers, division and remainder can be
|
||||
considered to partition the number line into a sequence of
|
||||
adjacent non-overlapping pieces, where each piece is the size of the divisor;
|
||||
the quotient identifies which piece the dividend lies within, and the
|
||||
remainder identifies where within that piece the dividend lies. A
|
||||
When applied to integers, the division and remainder operators can be
|
||||
considered to partition the number line into a sequence of equal-sized
|
||||
adjacent non-overlapping pieces where each piece is the size of the divisor;
|
||||
the division result identifies which piece the divisor lay within, and the
|
||||
remainder result identifies where within that piece the divisor lay. A
|
||||
consequence of this is that the result of
|
||||
.QW "-57 \fB/\fR 10"
|
||||
is always -6, and the result of
|
||||
@@ -148,157 +151,177 @@ is always 3.
|
||||
.TP 20
|
||||
\fB+\0\0\-\fR
|
||||
.
|
||||
Add and subtract. Valid for numeric operands.
|
||||
Add and subtract. Valid for any numeric operands.
|
||||
.TP 20
|
||||
\fB<<\0\0>>\fR
|
||||
.
|
||||
Left and right shift. Valid for integers.
|
||||
Left and right shift. Valid for integer operands only.
|
||||
A right shift always propagates the sign bit.
|
||||
.TP 20
|
||||
\fB<\0\0>\0\0<=\0\0>=\fR
|
||||
.
|
||||
Boolean less than, greater than, less than or equal, and greater than or equal.
|
||||
Boolean less, greater, less than or equal, and greater than or equal.
|
||||
Each operator produces 1 if the condition is true, 0 otherwise.
|
||||
These operators may be applied to strings as well as numeric operands,
|
||||
in which case string comparison is used.
|
||||
.TP 20
|
||||
\fB==\0\0!=\fR
|
||||
.
|
||||
Boolean equal and not equal.
|
||||
Boolean equal and not equal. Each operator produces a zero/one result.
|
||||
Valid for all operand types.
|
||||
.TP 20
|
||||
\fBeq\0\0ne\fR
|
||||
.
|
||||
Boolean string equal and string not equal.
|
||||
Boolean string equal and string not equal. Each operator produces a
|
||||
zero/one result. The operand types are interpreted only as strings.
|
||||
.TP 20
|
||||
\fBin\0\0ni\fR
|
||||
.
|
||||
List containment and negated list containment. The first argument is
|
||||
interpreted as a string, the second as a list. \fBin\fR tests for membership
|
||||
in the list, and \fBni\fR is the inverse.
|
||||
List containment and negated list containment. Each operator produces
|
||||
a zero/one result and treats its first argument as a string and its
|
||||
second argument as a Tcl list. The \fBin\fR operator indicates
|
||||
whether the first argument is a member of the second argument list;
|
||||
the \fBni\fR operator inverts the sense of the result.
|
||||
.TP 20
|
||||
\fB&\fR
|
||||
.
|
||||
Bit-wise AND. Valid for integer operands.
|
||||
Bit-wise AND. Valid for integer operands only.
|
||||
.TP 20
|
||||
\fB^\fR
|
||||
.
|
||||
Bit-wise exclusive OR. Valid for integer operands.
|
||||
Bit-wise exclusive OR. Valid for integer operands only.
|
||||
.TP 20
|
||||
\fB|\fR
|
||||
.
|
||||
Bit-wise OR. Valid for integer operands.
|
||||
Bit-wise OR. Valid for integer operands only.
|
||||
.TP 20
|
||||
\fB&&\fR
|
||||
.
|
||||
Logical AND. If both operands are true, the result is 1, or 0 otherwise.
|
||||
|
||||
Logical AND. Produces a 1 result if both operands are non-zero,
|
||||
0 otherwise.
|
||||
Valid for boolean and numeric (integers or floating-point) operands only.
|
||||
.TP 20
|
||||
\fB||\fR
|
||||
.
|
||||
Logical OR. If both operands are false, the result is 0, or 1 otherwise.
|
||||
Logical OR. Produces a 0 result if both operands are zero, 1 otherwise.
|
||||
Valid for boolean and numeric (integers or floating-point) operands only.
|
||||
.TP 20
|
||||
\fIx\fB?\fIy\fB:\fIz\fR
|
||||
.
|
||||
If-then-else, as in C. If \fIx\fR is false , the result is the value of
|
||||
\fIy\fR. Otherwise the result is the value of \fIz\fR.
|
||||
If-then-else, as in C. If \fIx\fR
|
||||
evaluates to non-zero, then the result is the value of \fIy\fR.
|
||||
Otherwise the result is the value of \fIz\fR.
|
||||
The \fIx\fR operand must have a boolean or numeric value.
|
||||
.PP
|
||||
The exponentiation operator promotes types in the same way that the multiply
|
||||
and divide operators do, and the result is is the same as the result of
|
||||
\fBpow\fR.
|
||||
Exponentiation groups right-to-left within a precedence level. Other binary
|
||||
operators group left-to-right. For example, the value of
|
||||
See the C manual for more details on the results
|
||||
produced by each operator.
|
||||
The exponentiation operator promotes types like the multiply and
|
||||
divide operators, and produces a result that is the same as the output
|
||||
of the \fBpow\fR function (after any type conversions.)
|
||||
All of the binary operators but exponentiation group left-to-right
|
||||
within the same precedence level; exponentiation groups right-to-left. For example, the command
|
||||
.PP
|
||||
.CS
|
||||
\fBexpr\fR {4*2 < 7}
|
||||
.CE
|
||||
.PP
|
||||
is 0, while the value of
|
||||
returns 0, while
|
||||
.PP
|
||||
.CS
|
||||
\fBexpr\fR {2**3**2}
|
||||
.CE
|
||||
.PP
|
||||
is 512.
|
||||
returns 512.
|
||||
.PP
|
||||
As in C, \fB&&\fR, \fB||\fR, and \fB?:\fR feature
|
||||
The \fB&&\fR, \fB||\fR, and \fB?:\fR operators have
|
||||
.QW "lazy evaluation" ,
|
||||
which means that operands are not evaluated if they are
|
||||
not needed to determine the outcome. For example, in
|
||||
just as in C, which means that operands are not evaluated if they are
|
||||
not needed to determine the outcome. For example, in the command
|
||||
.PP
|
||||
.CS
|
||||
\fBexpr\fR {$v ? [a] : [b]}
|
||||
.CE
|
||||
.PP
|
||||
only one of \fB[a]\fR or \fB[b]\fR is evaluated,
|
||||
depending on the value of \fB$v\fR. This is not true of the normal Tcl parser,
|
||||
so it is normally recommended to enclose the arguments to \fBexpr\fR in braces.
|
||||
Without braces, as in
|
||||
\fBexpr\fR $v ? [a] : [b]
|
||||
both \fB[a]\fR and \fB[b]\fR are evaluated before \fBexpr\fR is even called.
|
||||
.PP
|
||||
For more details on the results
|
||||
produced by each operator, see the documentation for C.
|
||||
only one of
|
||||
.QW \fB[a]\fR
|
||||
or
|
||||
.QW \fB[b]\fR
|
||||
will actually be evaluated,
|
||||
depending on the value of \fB$v\fR. Note, however, that this is
|
||||
only true if the entire expression is enclosed in braces; otherwise
|
||||
the Tcl parser will evaluate both
|
||||
.QW \fB[a]\fR
|
||||
and
|
||||
.QW \fB[b]\fR
|
||||
before invoking the \fBexpr\fR command.
|
||||
.SS "MATH FUNCTIONS"
|
||||
.PP
|
||||
A mathematical function such as \fBsin($x)\fR is replaced with a call to an ordinary
|
||||
Tcl command in the \fBtcl::mathfunc\fR namespace. The evaluation
|
||||
of an expression such as
|
||||
When the expression parser encounters a mathematical function
|
||||
such as \fBsin($x)\fR, it replaces it with a call to an ordinary
|
||||
Tcl function in the \fBtcl::mathfunc\fR namespace. The processing
|
||||
of an expression such as:
|
||||
.PP
|
||||
.CS
|
||||
\fBexpr\fR {sin($x+$y)}
|
||||
.CE
|
||||
.PP
|
||||
is the same in every way as the evaluation of
|
||||
is the same in every way as the processing of:
|
||||
.PP
|
||||
.CS
|
||||
\fBexpr\fR {[tcl::mathfunc::sin [\fBexpr\fR {$x+$y}]]}
|
||||
.CE
|
||||
.PP
|
||||
which in turn is the same as the evaluation of
|
||||
which in turn is the same as the processing of:
|
||||
.PP
|
||||
.CS
|
||||
tcl::mathfunc::sin [\fBexpr\fR {$x+$y}]
|
||||
.CE
|
||||
.PP
|
||||
\fBtcl::mathfunc::sin\fR is resolved as described in
|
||||
\fBNAMESPACE RESOLUTION\fR in the \fBnamespace\fR(n) documentation. Given the
|
||||
default value of \fBnamespace path\fR, \fB[namespace
|
||||
current]::tcl::mathfunc::sin\fR or \fB::tcl::mathfunc::sin\fR are the typical
|
||||
resolutions.
|
||||
The executor will search for \fBtcl::mathfunc::sin\fR using the usual
|
||||
rules for resolving functions in namespaces. Either
|
||||
\fB::tcl::mathfunc::sin\fR or \fB[namespace
|
||||
current]::tcl::mathfunc::sin\fR will satisfy the request, and others
|
||||
may as well (depending on the current \fBnamespace path\fR setting).
|
||||
.PP
|
||||
As in C, a mathematical function may accept multiple arguments separated by commas. Thus,
|
||||
Some mathematical functions have several arguments, separated by commas like in C. Thus:
|
||||
.PP
|
||||
.CS
|
||||
\fBexpr\fR {hypot($x,$y)}
|
||||
.CE
|
||||
.PP
|
||||
becomes
|
||||
ends up as
|
||||
.PP
|
||||
.CS
|
||||
tcl::mathfunc::hypot $x $y
|
||||
.CE
|
||||
.PP
|
||||
See the \fBmathfunc\fR(n) documentation for the math functions that are
|
||||
See the \fBmathfunc\fR(n) manual page for the math functions that are
|
||||
available by default.
|
||||
.SS "TYPES, OVERFLOW, AND PRECISION"
|
||||
.PP
|
||||
When needed to guarantee exact performance, internal computations involving
|
||||
integers use the LibTomMath multiple precision integer library. In Tcl releases
|
||||
prior to 8.5, integer calculations were performed using one of the C types
|
||||
All internal computations involving integers are done calling on the
|
||||
LibTomMath multiple precision integer library as required so that all
|
||||
integer calculations are performed exactly. Note that in Tcl releases
|
||||
prior to 8.5, integer calculations were performed with one of the C types
|
||||
\fIlong int\fR or \fITcl_WideInt\fR, causing implicit range truncation
|
||||
in those calculations where values overflowed the range of those types.
|
||||
Any code that relied on these implicit truncations should instead call
|
||||
\fBint()\fR or \fBwide()\fR, which do truncate.
|
||||
Any code that relied on these implicit truncations will need to explicitly
|
||||
add \fBint()\fR or \fBwide()\fR function calls to expressions at the points
|
||||
where such truncation is required to take place.
|
||||
.PP
|
||||
Internal floating-point computations are
|
||||
performed using the \fIdouble\fR C type.
|
||||
When converting a string to floating-point value, exponent overflow is
|
||||
All internal computations involving floating-point are
|
||||
done with the C type \fIdouble\fR.
|
||||
When converting a string to floating-point, exponent overflow is
|
||||
detected and results in the \fIdouble\fR value of \fBInf\fR or
|
||||
\fB\-Inf\fR as appropriate. Floating-point overflow and underflow
|
||||
are detected to the degree supported by the hardware, which is generally
|
||||
fairly reliable.
|
||||
pretty reliable.
|
||||
.PP
|
||||
Conversion among internal representations for integer, floating-point, and
|
||||
string operands is done automatically as needed. For arithmetic computations,
|
||||
integers are used until some floating-point number is introduced, after which
|
||||
floating-point values are used. For example,
|
||||
Conversion among internal representations for integer, floating-point,
|
||||
and string operands is done automatically as needed.
|
||||
For arithmetic computations, integers are used until some
|
||||
floating-point number is introduced, after which floating-point is used.
|
||||
For example,
|
||||
.PP
|
||||
.CS
|
||||
\fBexpr\fR {5 / 4}
|
||||
@@ -312,62 +335,82 @@ returns 1, while
|
||||
.CE
|
||||
.PP
|
||||
both return 1.25.
|
||||
A floating-point result can be distinguished from an integer result by the
|
||||
presence of either
|
||||
Floating-point values are always returned with a
|
||||
.QW \fB.\fR
|
||||
or
|
||||
or an
|
||||
.QW \fBe\fR
|
||||
.PP
|
||||
. For example,
|
||||
so that they will not look like integer values. For example,
|
||||
.PP
|
||||
.CS
|
||||
\fBexpr\fR {20.0/5.0}
|
||||
.CE
|
||||
.PP
|
||||
returns \fB4.0\fR, not \fB4\fR.
|
||||
.SS "STRING OPERATIONS"
|
||||
.PP
|
||||
String values may be used as operands of the comparison operators,
|
||||
although the expression evaluator tries to do comparisons as integer
|
||||
or floating-point when it can,
|
||||
i.e., when all arguments to the operator allow numeric interpretations,
|
||||
except in the case of the \fBeq\fR and \fBne\fR operators.
|
||||
If one of the operands of a comparison is a string and the other
|
||||
has a numeric value, a canonical string representation of the numeric
|
||||
operand value is generated to compare with the string operand.
|
||||
Canonical string representation for integer values is a decimal string
|
||||
format. Canonical string representation for floating-point values
|
||||
is that produced by the \fB%g\fR format specifier of Tcl's
|
||||
\fBformat\fR command. For example, the commands
|
||||
.PP
|
||||
.CS
|
||||
\fBexpr\fR {"0x03" > "2"}
|
||||
\fBexpr\fR {"0y" > "0x12"}
|
||||
.CE
|
||||
.PP
|
||||
both return 1. The first comparison is done using integer
|
||||
comparison, and the second is done using string comparison.
|
||||
Because of Tcl's tendency to treat values as numbers whenever
|
||||
possible, it is not generally a good idea to use operators like \fB==\fR
|
||||
when you really want string comparison and the values of the
|
||||
operands could be arbitrary; it is better in these cases to use
|
||||
the \fBeq\fR or \fBne\fR operators, or the \fBstring\fR command instead.
|
||||
.SH "PERFORMANCE CONSIDERATIONS"
|
||||
.PP
|
||||
Where an expression contains syntax that Tcl would otherwise perform
|
||||
substitutions on, enclosing an expression in braces or otherwise quoting it
|
||||
so that it's a static value allows the Tcl compiler to generate bytecode for
|
||||
the expression, resulting in better speed and smaller storage requirements.
|
||||
This also avoids issues that can arise if Tcl is allowed to perform
|
||||
substitution on the value before \fBexpr\fR is called.
|
||||
Enclose expressions in braces for the best speed and the smallest
|
||||
storage requirements.
|
||||
This allows the Tcl bytecode compiler to generate the best code.
|
||||
.PP
|
||||
As mentioned above, expressions are substituted twice:
|
||||
once by the Tcl parser and once by the \fBexpr\fR command.
|
||||
For example, the commands
|
||||
.PP
|
||||
In the following example, the value of the expression is 11 because the Tcl parser first
|
||||
substitutes \fB$b\fR and \fBexpr\fR then substitutes \fB$a\fR. Enclosing the
|
||||
expression in braces would result in a syntax error.
|
||||
.CS
|
||||
set a 3
|
||||
set b {$a + 2}
|
||||
\fBexpr\fR $b*4
|
||||
.CE
|
||||
.PP
|
||||
|
||||
When an expression is generated at runtime, like the one above is, the bytcode
|
||||
compiler must ensure that new code is generated each time the expression
|
||||
is evaluated. This is the most costly kind of expression from a performance
|
||||
perspective. In such cases, consider directly using the commands described in
|
||||
the \fBmathfunc\fR(n) or \fBmathop\fR(n) documentation instead of \fBexpr\fR.
|
||||
|
||||
Most expressions are not formed at runtime, but are literal strings or contain
|
||||
substitutions that don't introduce other substitutions. To allow the bytecode
|
||||
compiler to work with an expression as a string literal at compilation time,
|
||||
ensure that it contains no substitutions or that it is enclosed in braces or
|
||||
otherwise quoted to prevent Tcl from performing substitutions, allowing
|
||||
\fBexpr\fR to perform them instead.
|
||||
return 11, not a multiple of 4.
|
||||
This is because the Tcl parser will first substitute \fB$a + 2\fR for
|
||||
the variable \fBb\fR,
|
||||
then the \fBexpr\fR command will evaluate the expression \fB$a + 2*4\fR.
|
||||
.PP
|
||||
Most expressions do not require a second round of substitutions.
|
||||
Either they are enclosed in braces or, if not,
|
||||
their variable and command substitutions yield numbers or strings
|
||||
that do not themselves require substitutions.
|
||||
However, because a few unbraced expressions
|
||||
need two rounds of substitutions,
|
||||
the bytecode compiler must emit
|
||||
additional instructions to handle this situation.
|
||||
The most expensive code is required for
|
||||
unbraced expressions that contain command substitutions.
|
||||
These expressions must be implemented by generating new code
|
||||
each time the expression is executed.
|
||||
When the expression is unbraced to allow the substitution of a function or
|
||||
operator, consider using the commands documented in the \fBmathfunc\fR(n) or
|
||||
\fBmathop\fR(n) manual pages directly instead.
|
||||
.SH EXAMPLES
|
||||
.PP
|
||||
A numeric comparison whose result is 1:
|
||||
.CS
|
||||
\fBexpr\fR {"0x03" > "2"}
|
||||
.CE
|
||||
.PP
|
||||
A string comparison whose result is 1:
|
||||
.CS
|
||||
\fBexpr\fR {"0y" > "0x12"}
|
||||
.CE
|
||||
.PP
|
||||
Define a procedure that computes an
|
||||
.QW interesting
|
||||
mathematical function:
|
||||
@@ -401,8 +444,8 @@ each other:
|
||||
puts "a and b are [\fBexpr\fR {$a eq $b ? {equal} : {different}}]"
|
||||
.CE
|
||||
.PP
|
||||
Set a variable indicating whether an environment variable is defined and has
|
||||
value of true:
|
||||
Set a variable to whether an environment variable is both defined at
|
||||
all and also set to a true boolean value:
|
||||
.PP
|
||||
.CS
|
||||
set isTrue [\fBexpr\fR {
|
||||
|
||||
+1
-1
@@ -390,7 +390,7 @@ that use the third component do not attempt to perform tilde
|
||||
substitution.
|
||||
.RE
|
||||
.TP
|
||||
\fBfile stat \fIname varName\fR
|
||||
\fBfile stat \fIname varName\fR
|
||||
.
|
||||
Invokes the \fBstat\fR kernel call on \fIname\fR, and uses the variable
|
||||
given by \fIvarName\fR to hold information returned from the kernel call.
|
||||
|
||||
+1
-4
@@ -418,10 +418,7 @@ set token [::http::geturl https://my.secure.site/]
|
||||
\fB::http::unregister\fR \fIproto\fR
|
||||
.
|
||||
This procedure unregisters a protocol handler that was previously
|
||||
registered via \fB::http::register\fR, returning a two-item list of
|
||||
the default port and handler command that was previously installed
|
||||
(via \fB::http::register\fR) if there was such a handler, and an error if
|
||||
there was no such handler.
|
||||
registered via \fB::http::register\fR.
|
||||
.SH ERRORS
|
||||
The \fB::http::geturl\fR procedure will raise errors in the following cases:
|
||||
invalid command line options,
|
||||
|
||||
+3
-1
@@ -123,7 +123,9 @@ with conversion character \fBu\fR.
|
||||
.TP
|
||||
\fBi\fR
|
||||
.
|
||||
The input substring must be an integer. The base (i.e. decimal, octal, or hexadecimal) is determined by the C convention (leading 0 for octal; prefix 0x for hexadecimal). The integer value is stored in the variable,
|
||||
The input substring must be an integer. The base (i.e. decimal, binary,
|
||||
octal, or hexadecimal) is determined in the same fashion as described in
|
||||
\fBexpr\fR. The integer value is stored in the variable,
|
||||
truncated as required by the size modifier value.
|
||||
.TP
|
||||
\fBc\fR
|
||||
|
||||
+13
-3
@@ -12,14 +12,14 @@
|
||||
.SH NAME
|
||||
update \- Process pending events and idle callbacks
|
||||
.SH SYNOPSIS
|
||||
\fBupdate\fR ?\fBidletasks\fR?
|
||||
\fBupdate\fR ?\fIoption ...\fR?
|
||||
.BE
|
||||
.SH DESCRIPTION
|
||||
.PP
|
||||
This command is used to bring the application
|
||||
.QW "up to date"
|
||||
by entering the event loop repeatedly until all pending events
|
||||
(including idle callbacks) have been processed.
|
||||
(including idle callbacks, if specified) have been processed.
|
||||
.PP
|
||||
If the \fBidletasks\fR keyword is specified as an argument to the
|
||||
command, then no new events or errors are processed; only idle
|
||||
@@ -27,6 +27,16 @@ callbacks are invoked.
|
||||
This causes operations that are normally deferred, such as display
|
||||
updates and window layout calculations, to be performed immediately.
|
||||
.PP
|
||||
Options accepted are
|
||||
\fBidletasks\fR - process any pending window events or idle events, do not wait
|
||||
\fBwindow\fR - process window events
|
||||
\fBfile\fR - process file events
|
||||
\fBtimer\fR - process timer events
|
||||
\fBonlyidle\fR - process only idle events
|
||||
\fBall\fR - process all events
|
||||
\fBwait\fR - wait until at least one event has been processed
|
||||
\fBnowait\fR - return immediately if no events are pending.
|
||||
.PP
|
||||
The \fBupdate idletasks\fR command is useful in scripts where
|
||||
changes have been made to the application's state and you want those
|
||||
changes to appear on the display immediately, rather than waiting
|
||||
@@ -60,6 +70,6 @@ while {!$done} {
|
||||
}
|
||||
.CE
|
||||
.SH "SEE ALSO"
|
||||
after(n), interp(n)
|
||||
after(n), interp(n), Tcl_DoOneEvent(3)
|
||||
.SH KEYWORDS
|
||||
asynchronous I/O, event, flush, handler, idle, update
|
||||
|
||||
+1
-6
@@ -45,8 +45,7 @@ linked to the corresponding namespace variables (and therefore these
|
||||
variables are listed by \fBinfo vars\fR.)
|
||||
In this way the \fBvariable\fR command resembles the \fBglobal\fR command,
|
||||
although the \fBglobal\fR command
|
||||
resolves variable names with respect to the global namespace instead
|
||||
of the current namespace of the procedure.
|
||||
only links to variables in the global namespace.
|
||||
If any \fIvalue\fRs are given,
|
||||
they are used to modify the values of the associated namespace variables.
|
||||
If a namespace variable does not exist,
|
||||
@@ -99,7 +98,3 @@ namespace eval foo {
|
||||
global(n), namespace(n), upvar(n)
|
||||
.SH KEYWORDS
|
||||
global, namespace, procedure, variable
|
||||
.\" Local variables:
|
||||
.\" mode: nroff
|
||||
.\" fill-column: 78
|
||||
.\" End:
|
||||
|
||||
+3
-3
@@ -457,7 +457,7 @@ next(
|
||||
if (ATEOS()) {
|
||||
FAILW(REG_EESCAPE);
|
||||
}
|
||||
(void)lexescape(v);
|
||||
(DISCARD)lexescape(v);
|
||||
switch (v->nexttype) { /* not all escapes okay here */
|
||||
case PLAIN:
|
||||
return 1;
|
||||
@@ -716,7 +716,7 @@ next(
|
||||
}
|
||||
RETV(PLAIN, *v->now++);
|
||||
}
|
||||
(void)lexescape(v);
|
||||
(DISCARD)lexescape(v);
|
||||
if (ISERR()) {
|
||||
FAILW(REG_EESCAPE);
|
||||
}
|
||||
@@ -1143,7 +1143,7 @@ skip(
|
||||
/*
|
||||
- newline - return the chr for a newline
|
||||
* This helps confine use of CHR to this source file.
|
||||
^ static chr newline(void);
|
||||
^ static chr newline(NOPARMS);
|
||||
*/
|
||||
static chr
|
||||
newline(void)
|
||||
|
||||
@@ -1227,7 +1227,7 @@ cmp(
|
||||
const chr *x, const chr *y, /* strings to compare */
|
||||
size_t len) /* exact length of comparison */
|
||||
{
|
||||
return memcmp((void*)(x), (void*)(y), len*sizeof(chr));
|
||||
return memcmp(VS(x), VS(y), len*sizeof(chr));
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
+2
-2
@@ -843,7 +843,7 @@ moveins(
|
||||
|
||||
/*
|
||||
- copyins - copy in arcs of a state to another state
|
||||
^ static void copyins(struct nfa *, struct state *, struct state *, int);
|
||||
^ static VOID copyins(struct nfa *, struct state *, struct state *, int);
|
||||
*/
|
||||
static void
|
||||
copyins(
|
||||
@@ -1100,7 +1100,7 @@ moveouts(
|
||||
|
||||
/*
|
||||
- copyouts - copy out arcs of a state to another state
|
||||
^ static void copyouts(struct nfa *, struct state *, struct state *, int);
|
||||
^ static VOID copyouts(struct nfa *, struct state *, struct state *, int);
|
||||
*/
|
||||
static void
|
||||
copyouts(
|
||||
|
||||
+6
-6
@@ -82,7 +82,7 @@ static int lexescape(struct vars *);
|
||||
static int lexdigits(struct vars *, int, int, int);
|
||||
static int brenext(struct vars *, pchr);
|
||||
static void skip(struct vars *);
|
||||
static chr newline(void);
|
||||
static chr newline(NOPARMS);
|
||||
static chr chrnamed(struct vars *, const chr *, const chr *, pchr);
|
||||
/* === regc_color.c === */
|
||||
static void initcm(struct vars *, struct colormap *);
|
||||
@@ -341,13 +341,13 @@ compile(
|
||||
re->re_info = 0; /* bits get set during parse */
|
||||
re->re_csize = sizeof(chr);
|
||||
re->re_guts = NULL;
|
||||
re->re_fns = (void*)(&functions);
|
||||
re->re_fns = VS(&functions);
|
||||
|
||||
/*
|
||||
* More complex setup, malloced things.
|
||||
*/
|
||||
|
||||
re->re_guts = (void*)(MALLOC(sizeof(struct guts)));
|
||||
re->re_guts = VS(MALLOC(sizeof(struct guts)));
|
||||
if (re->re_guts == NULL) {
|
||||
return freev(v, REG_ESPACE);
|
||||
}
|
||||
@@ -434,7 +434,7 @@ compile(
|
||||
* Can sacrifice main NFA now, so use it as work area.
|
||||
*/
|
||||
|
||||
(void) optimize(v->nfa, debug);
|
||||
(DISCARD) optimize(v->nfa, debug);
|
||||
CNOERR();
|
||||
makesearch(v, v->nfa);
|
||||
CNOERR();
|
||||
@@ -1920,10 +1920,10 @@ nfatree(
|
||||
assert(t != NULL && t->begin != NULL);
|
||||
|
||||
if (t->left != NULL) {
|
||||
(void) nfatree(v, t->left, f);
|
||||
(DISCARD) nfatree(v, t->left, f);
|
||||
}
|
||||
if (t->right != NULL) {
|
||||
(void) nfatree(v, t->right, f);
|
||||
(DISCARD) nfatree(v, t->right, f);
|
||||
}
|
||||
|
||||
return nfanode(v, t, f);
|
||||
|
||||
+4
-3
@@ -36,9 +36,10 @@
|
||||
* Overrides for regguts.h definitions, if any.
|
||||
*/
|
||||
|
||||
#define MALLOC(n) (void*)(attemptckalloc(n))
|
||||
#define FREE(p) ckfree((void*)(p))
|
||||
#define REALLOC(p,n) (void*)(attemptckrealloc((void*)(p),n))
|
||||
#define FUNCPTR(name, args) (*name)args
|
||||
#define MALLOC(n) VS(attemptckalloc(n))
|
||||
#define FREE(p) ckfree(VS(p))
|
||||
#define REALLOC(p,n) VS(attemptckrealloc(VS(p),n))
|
||||
|
||||
/*
|
||||
* Do not insert extras between the "begin" and "end" lines - this chunk is
|
||||
|
||||
+2
-2
@@ -44,7 +44,7 @@ struct sset { /* state set */
|
||||
unsigned hash; /* hash of bitvector */
|
||||
#define HASH(bv, nw) (((nw) == 1) ? *(bv) : hash(bv, nw))
|
||||
#define HIT(h,bv,ss,nw) ((ss)->hash == (h) && ((nw) == 1 || \
|
||||
memcmp((void*)(bv), (void*)((ss)->states), (nw)*sizeof(unsigned)) == 0))
|
||||
memcmp(VS(bv), VS((ss)->states), (nw)*sizeof(unsigned)) == 0))
|
||||
int flags;
|
||||
#define STARTER 01 /* the initial state set */
|
||||
#define POSTSTATE 02 /* includes the goal state */
|
||||
@@ -268,7 +268,7 @@ exec(
|
||||
if (st == REG_OKAY && v->pmatch != pmatch && nmatch > 0) {
|
||||
zapallsubs(pmatch, nmatch);
|
||||
n = (nmatch < v->nmatch) ? nmatch : v->nmatch;
|
||||
memcpy((void*)(pmatch), (void*)(v->pmatch), n*sizeof(regmatch_t));
|
||||
memcpy(VS(pmatch), VS(v->pmatch), n*sizeof(regmatch_t));
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
+30
-4
@@ -49,15 +49,41 @@
|
||||
#include <assert.h>
|
||||
#endif
|
||||
|
||||
/* voids */
|
||||
#ifndef VOID
|
||||
#define VOID void /* for function return values */
|
||||
#endif
|
||||
#ifndef DISCARD
|
||||
#define DISCARD void /* for throwing values away */
|
||||
#endif
|
||||
#ifndef PVOID
|
||||
#define PVOID void * /* generic pointer */
|
||||
#endif
|
||||
#ifndef VS
|
||||
#define VS(x) ((void*)(x)) /* cast something to generic ptr */
|
||||
#endif
|
||||
#ifndef NOPARMS
|
||||
#define NOPARMS void /* for empty parm lists */
|
||||
#endif
|
||||
|
||||
/* function-pointer declarator */
|
||||
#ifndef FUNCPTR
|
||||
#if __STDC__ >= 1
|
||||
#define FUNCPTR(name, args) (*name)args
|
||||
#else
|
||||
#define FUNCPTR(name, args) (*name)()
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/* memory allocation */
|
||||
#ifndef MALLOC
|
||||
#define MALLOC(n) malloc(n)
|
||||
#endif
|
||||
#ifndef REALLOC
|
||||
#define REALLOC(p, n) realloc(p, n)
|
||||
#define REALLOC(p, n) realloc(VS(p), n)
|
||||
#endif
|
||||
#ifndef FREE
|
||||
#define FREE(p) free(p)
|
||||
#define FREE(p) free(VS(p))
|
||||
#endif
|
||||
|
||||
/* want size of a char in bits, and max value in bounded quantifiers */
|
||||
@@ -382,7 +408,7 @@ struct subre {
|
||||
*/
|
||||
|
||||
struct fns {
|
||||
void (*free) (regex_t *);
|
||||
void FUNCPTR(free, (regex_t *));
|
||||
};
|
||||
|
||||
/*
|
||||
@@ -399,7 +425,7 @@ struct guts {
|
||||
struct cnfa search; /* for fast preliminary search */
|
||||
int ntree; /* number of subre's, plus one */
|
||||
struct colormap cmap;
|
||||
int (*compare) (const chr *, const chr *, size_t);
|
||||
int FUNCPTR(compare, (const chr *, const chr *, size_t));
|
||||
struct subre *lacons; /* lookahead-constraint vector */
|
||||
int nlacons; /* size of lacons */
|
||||
};
|
||||
|
||||
+11
-10
@@ -831,20 +831,19 @@ typedef struct Tcl_Obj {
|
||||
union { /* The internal representation: */
|
||||
long longValue; /* - an long integer value. */
|
||||
double doubleValue; /* - a double-precision floating value. */
|
||||
void *otherValuePtr; /* - another, type-specific value, not used
|
||||
* internally any more. */
|
||||
void *otherValuePtr; /* - another, type-specific value,
|
||||
not used internally any more. */
|
||||
Tcl_WideInt wideValue; /* - a long long value. */
|
||||
struct { /* - internal rep as two pointers.
|
||||
* Many uses in Tcl, including a bignum's
|
||||
* the main use of which is a bignum's
|
||||
* tightly packed fields, where the alloc,
|
||||
* used and signum flags are packed into
|
||||
* ptr2 with everything else hung off
|
||||
* ptr1. */
|
||||
* ptr2 with everything else hung off ptr1. */
|
||||
void *ptr1;
|
||||
void *ptr2;
|
||||
} twoPtrValue;
|
||||
struct { /* - internal rep as a pointer and a long,
|
||||
* not used internally any more. */
|
||||
not used internally any more. */
|
||||
void *ptr;
|
||||
unsigned long value;
|
||||
} ptrAndLongRep;
|
||||
@@ -1320,9 +1319,9 @@ typedef struct Tcl_HashSearch {
|
||||
* TCL_CUSTOM_PTR_KEYS: The keys are pointers to arbitrary types, the
|
||||
* pointer is stored in the entry.
|
||||
*
|
||||
* While maintaining binary compatibility the above have to be distinct values
|
||||
* While maintaining binary compatability the above have to be distinct values
|
||||
* as they are used to differentiate between old versions of the hash table
|
||||
* which don't have a typePtr and new ones which do. Once binary compatibility
|
||||
* which don't have a typePtr and new ones which do. Once binary compatability
|
||||
* is discarded in favour of making more wide spread changes TCL_STRING_KEYS
|
||||
* can be the same as TCL_CUSTOM_TYPE_KEYS, and TCL_ONE_WORD_KEYS can be the
|
||||
* same as TCL_CUSTOM_PTR_KEYS because they simply determine how the key is
|
||||
@@ -2409,6 +2408,10 @@ const char * TclTomMathInitializeStubs(Tcl_Interp *interp,
|
||||
(exact)|(TCL_MAJOR_VERSION<<8)|(TCL_MINOR_VERSION<<16))
|
||||
#endif
|
||||
|
||||
/*
|
||||
* TODO - tommath stubs export goes here!
|
||||
*/
|
||||
|
||||
/*
|
||||
* Public functions that are not accessible via the stubs table.
|
||||
* Tcl_GetMemoryInfo is needed for AOLserver. [Bug 1868171]
|
||||
@@ -2616,9 +2619,7 @@ EXTERN void Tcl_GetMemoryInfo(Tcl_DString *dsPtr);
|
||||
# define Tcl_Ckrealloc Tcl_Realloc
|
||||
# define Tcl_Return Tcl_SetResult
|
||||
# define Tcl_TildeSubst Tcl_TranslateFileName
|
||||
#if !defined(__APPLE__) /* On OSX, there is a conflict with "mach/mach.h" */
|
||||
# define panic Tcl_Panic
|
||||
#endif
|
||||
# define panicVA Tcl_PanicVA
|
||||
#endif /* !TCL_NO_DEPRECATED */
|
||||
|
||||
|
||||
+22
-22
@@ -32,7 +32,7 @@
|
||||
*/
|
||||
|
||||
#if defined(_MSC_VER) || defined(__MSVCRT__) || defined(__BORLANDC__)
|
||||
typedef size_t caddr_t;
|
||||
typedef unsigned long caddr_t;
|
||||
#endif
|
||||
|
||||
/*
|
||||
@@ -56,7 +56,7 @@ union overhead {
|
||||
unsigned char magic1; /* other magic number */
|
||||
#ifndef NDEBUG
|
||||
unsigned short rmagic; /* range magic number */
|
||||
size_t size; /* actual block size */
|
||||
unsigned long size; /* actual block size */
|
||||
unsigned short unused2; /* padding to 8-byte align */
|
||||
#endif
|
||||
} ovu;
|
||||
@@ -133,7 +133,7 @@ static int allocInit = 0;
|
||||
* a given block size.
|
||||
*/
|
||||
|
||||
static size_t numMallocs[NBUCKETS+1];
|
||||
static unsigned int numMallocs[NBUCKETS+1];
|
||||
#endif
|
||||
|
||||
#if !defined(NDEBUG)
|
||||
@@ -148,7 +148,7 @@ static size_t numMallocs[NBUCKETS+1];
|
||||
* Prototypes for functions used only in this file.
|
||||
*/
|
||||
|
||||
static void MoreCore(size_t bucket);
|
||||
static void MoreCore(int bucket);
|
||||
|
||||
/*
|
||||
*-------------------------------------------------------------------------
|
||||
@@ -254,7 +254,7 @@ TclpAlloc(
|
||||
unsigned int numBytes) /* Number of bytes to allocate. */
|
||||
{
|
||||
register union overhead *overPtr;
|
||||
register size_t bucket;
|
||||
register long bucket;
|
||||
register unsigned amount;
|
||||
struct block *bigBlockPtr = NULL;
|
||||
|
||||
@@ -385,12 +385,12 @@ TclpAlloc(
|
||||
|
||||
static void
|
||||
MoreCore(
|
||||
size_t bucket) /* What bucket to allocate to. */
|
||||
int bucket) /* What bucket to allocat to. */
|
||||
{
|
||||
register union overhead *overPtr;
|
||||
register size_t size; /* size of desired block */
|
||||
size_t amount; /* amount to allocate */
|
||||
size_t numBlocks; /* how many blocks we get */
|
||||
register long size; /* size of desired block */
|
||||
long amount; /* amount to allocate */
|
||||
int numBlocks; /* how many blocks we get */
|
||||
struct block *blockPtr;
|
||||
|
||||
/*
|
||||
@@ -398,14 +398,14 @@ MoreCore(
|
||||
* VAX, I think) or for a negative arg.
|
||||
*/
|
||||
|
||||
size = ((size_t)1) << (bucket + 3);
|
||||
size = 1 << (bucket + 3);
|
||||
ASSERT(size > 0);
|
||||
|
||||
amount = MAXMALLOC;
|
||||
numBlocks = amount / size;
|
||||
ASSERT(numBlocks*size == amount);
|
||||
|
||||
blockPtr = (struct block *) TclpSysAlloc(
|
||||
blockPtr = (struct block *) TclpSysAlloc((unsigned)
|
||||
(sizeof(struct block) + amount), 1);
|
||||
/* no more room! */
|
||||
if (blockPtr == NULL) {
|
||||
@@ -448,7 +448,7 @@ void
|
||||
TclpFree(
|
||||
char *oldPtr) /* Pointer to memory to free. */
|
||||
{
|
||||
register size_t size;
|
||||
register long size;
|
||||
register union overhead *overPtr;
|
||||
struct block *bigBlockPtr;
|
||||
|
||||
@@ -518,7 +518,7 @@ TclpRealloc(
|
||||
union overhead *overPtr;
|
||||
struct block *bigBlockPtr;
|
||||
int expensive;
|
||||
size_t maxSize;
|
||||
unsigned long maxSize;
|
||||
|
||||
if (oldPtr == NULL) {
|
||||
return TclpAlloc(numBytes);
|
||||
@@ -645,30 +645,30 @@ void
|
||||
mstats(
|
||||
char *s) /* Where to write info. */
|
||||
{
|
||||
register unsigned int i, j;
|
||||
register int i, j;
|
||||
register union overhead *overPtr;
|
||||
size_t totalFree = 0, totalUsed = 0;
|
||||
int totalFree = 0, totalUsed = 0;
|
||||
|
||||
Tcl_MutexLock(allocMutexPtr);
|
||||
|
||||
fprintf(stderr, "Memory allocation statistics %s\nTclpFree:\t", s);
|
||||
for (i = 0; i < NBUCKETS; i++) {
|
||||
for (j=0, overPtr=nextf[i]; overPtr; overPtr=overPtr->next, j++) {
|
||||
fprintf(stderr, " %u", j);
|
||||
fprintf(stderr, " %d", j);
|
||||
}
|
||||
totalFree += ((size_t)j) * (1 << (i + 3));
|
||||
totalFree += j * (1 << (i + 3));
|
||||
}
|
||||
|
||||
fprintf(stderr, "\nused:\t");
|
||||
for (i = 0; i < NBUCKETS; i++) {
|
||||
fprintf(stderr, " %" TCL_LL_MODIFIER "d", (Tcl_WideInt)numMallocs[i]);
|
||||
fprintf(stderr, " %d", numMallocs[i]);
|
||||
totalUsed += numMallocs[i] * (1 << (i + 3));
|
||||
}
|
||||
|
||||
fprintf(stderr, "\n\tTotal small in use: %" TCL_LL_MODIFIER "d, total free: %" TCL_LL_MODIFIER "d\n",
|
||||
(Tcl_WideInt)totalUsed, (Tcl_WideInt)totalFree);
|
||||
fprintf(stderr, "\n\tNumber of big (>%d) blocks in use: %" TCL_LL_MODIFIER "d\n",
|
||||
MAXMALLOC, (Tcl_WideInt)numMallocs[NBUCKETS]);
|
||||
fprintf(stderr, "\n\tTotal small in use: %d, total free: %d\n",
|
||||
totalUsed, totalFree);
|
||||
fprintf(stderr, "\n\tNumber of big (>%d) blocks in use: %d\n",
|
||||
MAXMALLOC, numMallocs[NBUCKETS]);
|
||||
|
||||
Tcl_MutexUnlock(allocMutexPtr);
|
||||
}
|
||||
|
||||
+23
-23
@@ -1300,7 +1300,7 @@ AssembleOneLine(
|
||||
goto cleanup;
|
||||
}
|
||||
operand1 = TclGetStringFromObj(operand1Obj, &operand1Len);
|
||||
litIndex = TclRegisterLiteral(envPtr, operand1, operand1Len, 0);
|
||||
litIndex = TclRegisterNewLiteral(envPtr, operand1, operand1Len);
|
||||
BBEmitInst1or4(assemEnvPtr, tblIdx, litIndex, 0);
|
||||
break;
|
||||
|
||||
@@ -1449,7 +1449,7 @@ AssembleOneLine(
|
||||
goto cleanup;
|
||||
} else {
|
||||
operand1 = TclGetStringFromObj(operand1Obj, &operand1Len);
|
||||
litIndex = TclRegisterLiteral(envPtr, operand1, operand1Len, 0);
|
||||
litIndex = TclRegisterNewLiteral(envPtr, operand1, operand1Len);
|
||||
|
||||
/*
|
||||
* Assumes that PUSH is the first slot!
|
||||
@@ -1543,7 +1543,7 @@ AssembleOneLine(
|
||||
* Add the (label_name, address) pair to the hash table.
|
||||
*/
|
||||
|
||||
if (DefineLabel(assemEnvPtr, TclGetString(operand1Obj)) != TCL_OK) {
|
||||
if (DefineLabel(assemEnvPtr, Tcl_GetString(operand1Obj)) != TCL_OK) {
|
||||
goto cleanup;
|
||||
}
|
||||
break;
|
||||
@@ -1722,7 +1722,7 @@ AssembleOneLine(
|
||||
|
||||
default:
|
||||
Tcl_Panic("Instruction \"%s\" could not be found, can't happen\n",
|
||||
TclGetString(instNameObj));
|
||||
Tcl_GetString(instNameObj));
|
||||
}
|
||||
|
||||
status = TCL_OK;
|
||||
@@ -1985,15 +1985,15 @@ CreateMirrorJumpTable(
|
||||
|
||||
DEBUG_PRINT("jump table {\n");
|
||||
for (i = 0; i < objc; i+=2) {
|
||||
DEBUG_PRINT(" %s -> %s\n", TclGetString(objv[i]),
|
||||
TclGetString(objv[i+1]));
|
||||
hashEntry = Tcl_CreateHashEntry(jtHashPtr, TclGetString(objv[i]),
|
||||
DEBUG_PRINT(" %s -> %s\n", Tcl_GetString(objv[i]),
|
||||
Tcl_GetString(objv[i+1]));
|
||||
hashEntry = Tcl_CreateHashEntry(jtHashPtr, Tcl_GetString(objv[i]),
|
||||
&isNew);
|
||||
if (!isNew) {
|
||||
if (assemEnvPtr->flags & TCL_EVAL_DIRECT) {
|
||||
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
|
||||
"duplicate entry in jump table for \"%s\"",
|
||||
TclGetString(objv[i])));
|
||||
Tcl_GetString(objv[i])));
|
||||
Tcl_SetErrorCode(interp, "TCL", "ASSEM", "DUPJUMPTABLEENTRY");
|
||||
DeleteMirrorJumpTable(jtPtr);
|
||||
return TCL_ERROR;
|
||||
@@ -2801,7 +2801,7 @@ CalculateJumpRelocations(
|
||||
|
||||
if (bbPtr->jumpTarget != NULL) {
|
||||
entry = Tcl_FindHashEntry(&assemEnvPtr->labelHash,
|
||||
TclGetString(bbPtr->jumpTarget));
|
||||
Tcl_GetString(bbPtr->jumpTarget));
|
||||
if (entry == NULL) {
|
||||
ReportUndefinedLabel(assemEnvPtr, bbPtr,
|
||||
bbPtr->jumpTarget);
|
||||
@@ -2882,10 +2882,10 @@ CheckJumpTableLabels(
|
||||
symEntryPtr = Tcl_NextHashEntry(&search)) {
|
||||
symbolObj = Tcl_GetHashValue(symEntryPtr);
|
||||
valEntryPtr = Tcl_FindHashEntry(&assemEnvPtr->labelHash,
|
||||
TclGetString(symbolObj));
|
||||
Tcl_GetString(symbolObj));
|
||||
DEBUG_PRINT(" %s -> %s (%d)\n",
|
||||
(char*) Tcl_GetHashKey(symHash, symEntryPtr),
|
||||
TclGetString(symbolObj), (valEntryPtr != NULL));
|
||||
Tcl_GetString(symbolObj), (valEntryPtr != NULL));
|
||||
if (valEntryPtr == NULL) {
|
||||
ReportUndefinedLabel(assemEnvPtr, bbPtr, symbolObj);
|
||||
return TCL_ERROR;
|
||||
@@ -2923,9 +2923,9 @@ ReportUndefinedLabel(
|
||||
|
||||
if (assemEnvPtr->flags & TCL_EVAL_DIRECT) {
|
||||
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
|
||||
"undefined label \"%s\"", TclGetString(jumpTarget)));
|
||||
"undefined label \"%s\"", Tcl_GetString(jumpTarget)));
|
||||
Tcl_SetErrorCode(interp, "TCL", "ASSEM", "NOLABEL",
|
||||
TclGetString(jumpTarget), NULL);
|
||||
Tcl_GetString(jumpTarget), NULL);
|
||||
Tcl_SetErrorLine(interp, bbPtr->jumpLine);
|
||||
}
|
||||
}
|
||||
@@ -3008,7 +3008,7 @@ FillInJumpOffsets(
|
||||
bbPtr = bbPtr->successor1) {
|
||||
if (bbPtr->jumpTarget != NULL) {
|
||||
entry = Tcl_FindHashEntry(&assemEnvPtr->labelHash,
|
||||
TclGetString(bbPtr->jumpTarget));
|
||||
Tcl_GetString(bbPtr->jumpTarget));
|
||||
jumpTarget = Tcl_GetHashValue(entry);
|
||||
fromOffset = bbPtr->jumpOffset;
|
||||
targetOffset = jumpTarget->startOffset;
|
||||
@@ -3080,17 +3080,17 @@ ResolveJumpTableTargets(
|
||||
symEntryPtr != NULL;
|
||||
symEntryPtr = Tcl_NextHashEntry(&search)) {
|
||||
symbolObj = Tcl_GetHashValue(symEntryPtr);
|
||||
DEBUG_PRINT(" symbol %s\n", TclGetString(symbolObj));
|
||||
DEBUG_PRINT(" symbol %s\n", Tcl_GetString(symbolObj));
|
||||
|
||||
valEntryPtr = Tcl_FindHashEntry(&assemEnvPtr->labelHash,
|
||||
TclGetString(symbolObj));
|
||||
Tcl_GetString(symbolObj));
|
||||
jumpTargetBBPtr = Tcl_GetHashValue(valEntryPtr);
|
||||
|
||||
realJumpEntryPtr = Tcl_CreateHashEntry(realJumpHashPtr,
|
||||
Tcl_GetHashKey(symHash, symEntryPtr), &junk);
|
||||
DEBUG_PRINT(" %s -> %s -> bb %p (pc %d) hash entry %p\n",
|
||||
(char*) Tcl_GetHashKey(symHash, symEntryPtr),
|
||||
TclGetString(symbolObj), jumpTargetBBPtr,
|
||||
Tcl_GetString(symbolObj), jumpTargetBBPtr,
|
||||
jumpTargetBBPtr->startOffset, realJumpEntryPtr);
|
||||
|
||||
Tcl_SetHashValue(realJumpEntryPtr,
|
||||
@@ -3462,7 +3462,7 @@ StackCheckBasicBlock(
|
||||
|
||||
if (result == TCL_OK && blockPtr->jumpTarget != NULL) {
|
||||
entry = Tcl_FindHashEntry(&assemEnvPtr->labelHash,
|
||||
TclGetString(blockPtr->jumpTarget));
|
||||
Tcl_GetString(blockPtr->jumpTarget));
|
||||
jumpTarget = Tcl_GetHashValue(entry);
|
||||
result = StackCheckBasicBlock(assemEnvPtr, jumpTarget, blockPtr,
|
||||
stackDepth);
|
||||
@@ -3479,7 +3479,7 @@ StackCheckBasicBlock(
|
||||
jtEntry = Tcl_NextHashEntry(&jtSearch)) {
|
||||
targetLabel = Tcl_GetHashValue(jtEntry);
|
||||
entry = Tcl_FindHashEntry(&assemEnvPtr->labelHash,
|
||||
TclGetString(targetLabel));
|
||||
Tcl_GetString(targetLabel));
|
||||
jumpTarget = Tcl_GetHashValue(entry);
|
||||
result = StackCheckBasicBlock(assemEnvPtr, jumpTarget,
|
||||
blockPtr, stackDepth);
|
||||
@@ -3541,7 +3541,7 @@ StackCheckExit(
|
||||
* Emit a 'push' of the empty literal.
|
||||
*/
|
||||
|
||||
litIndex = TclRegisterLiteral(envPtr, "", 0, 0);
|
||||
litIndex = TclRegisterNewLiteral(envPtr, "", 0);
|
||||
|
||||
/*
|
||||
* Assumes that 'push' is at slot 0 in TalInstructionTable.
|
||||
@@ -3784,7 +3784,7 @@ ProcessCatchesInBasicBlock(
|
||||
}
|
||||
if (result == TCL_OK && bbPtr->jumpTarget != NULL) {
|
||||
entry = Tcl_FindHashEntry(&assemEnvPtr->labelHash,
|
||||
TclGetString(bbPtr->jumpTarget));
|
||||
Tcl_GetString(bbPtr->jumpTarget));
|
||||
jumpTarget = Tcl_GetHashValue(entry);
|
||||
result = ProcessCatchesInBasicBlock(assemEnvPtr, jumpTarget,
|
||||
jumpEnclosing, jumpState, catchDepth);
|
||||
@@ -3800,7 +3800,7 @@ ProcessCatchesInBasicBlock(
|
||||
jtEntry = Tcl_NextHashEntry(&jtSearch)) {
|
||||
targetLabel = Tcl_GetHashValue(jtEntry);
|
||||
entry = Tcl_FindHashEntry(&assemEnvPtr->labelHash,
|
||||
TclGetString(targetLabel));
|
||||
Tcl_GetString(targetLabel));
|
||||
jumpTarget = Tcl_GetHashValue(entry);
|
||||
result = ProcessCatchesInBasicBlock(assemEnvPtr, jumpTarget,
|
||||
jumpEnclosing, jumpState, catchDepth);
|
||||
@@ -4104,7 +4104,7 @@ StackFreshCatches(
|
||||
range->codeOffset = bbPtr->startOffset;
|
||||
|
||||
entryPtr = Tcl_FindHashEntry(&assemEnvPtr->labelHash,
|
||||
TclGetString(catch->jumpTarget));
|
||||
Tcl_GetString(catch->jumpTarget));
|
||||
if (entryPtr == NULL) {
|
||||
Tcl_Panic("undefined label in tclAssembly.c:"
|
||||
"BuildExceptionRanges, can't happen");
|
||||
|
||||
+21
-27
@@ -588,7 +588,7 @@ Tcl_CreateInterp(void)
|
||||
|
||||
iPtr->cmdCount = 0;
|
||||
TclInitLiteralTable(&iPtr->literalTable);
|
||||
iPtr->compileEpoch = 1;
|
||||
iPtr->compileEpoch = 0;
|
||||
iPtr->compiledProcPtr = NULL;
|
||||
iPtr->resolverPtr = NULL;
|
||||
iPtr->evalFlags = 0;
|
||||
@@ -966,11 +966,11 @@ Tcl_CreateInterp(void)
|
||||
Tcl_PkgProvideEx(interp, "Tcl", TCL_PATCH_LEVEL, &tclStubs);
|
||||
|
||||
if (TclTommath_Init(interp) != TCL_OK) {
|
||||
Tcl_Panic("%s", TclGetString(Tcl_GetObjResult(interp)));
|
||||
Tcl_Panic("%s", Tcl_GetString(Tcl_GetObjResult(interp)));
|
||||
}
|
||||
|
||||
if (TclOOInit(interp) != TCL_OK) {
|
||||
Tcl_Panic("%s", TclGetString(Tcl_GetObjResult(interp)));
|
||||
Tcl_Panic("%s", Tcl_GetString(Tcl_GetObjResult(interp)));
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -980,7 +980,7 @@ Tcl_CreateInterp(void)
|
||||
|
||||
#ifdef HAVE_ZLIB
|
||||
if (TclZlibInit(interp) != TCL_OK) {
|
||||
Tcl_Panic("%s", TclGetString(Tcl_GetObjResult(interp)));
|
||||
Tcl_Panic("%s", Tcl_GetString(Tcl_GetObjResult(interp)));
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -1635,7 +1635,7 @@ DeleteInterpProc(
|
||||
}
|
||||
|
||||
Tcl_DeleteHashTable(iPtr->lineLAPtr);
|
||||
ckfree(iPtr->lineLAPtr);
|
||||
ckfree((char *) iPtr->lineLAPtr);
|
||||
iPtr->lineLAPtr = NULL;
|
||||
|
||||
if (iPtr->lineLABCPtr->numEntries && !TclInExit()) {
|
||||
@@ -2403,7 +2403,7 @@ TclInvokeStringCommand(
|
||||
TclStackAlloc(interp, (unsigned)(objc + 1) * sizeof(char *));
|
||||
|
||||
for (i = 0; i < objc; i++) {
|
||||
argv[i] = TclGetString(objv[i]);
|
||||
argv[i] = Tcl_GetString(objv[i]);
|
||||
}
|
||||
argv[objc] = 0;
|
||||
|
||||
@@ -2657,7 +2657,7 @@ TclRenameCommand(
|
||||
}
|
||||
Tcl_DStringAppend(&newFullName, newTail, -1);
|
||||
cmdPtr->refCount++;
|
||||
CallCommandTraces(iPtr, cmdPtr, TclGetString(oldFullName),
|
||||
CallCommandTraces(iPtr, cmdPtr, Tcl_GetString(oldFullName),
|
||||
Tcl_DStringValue(&newFullName), TCL_TRACE_RENAME);
|
||||
Tcl_DStringFree(&newFullName);
|
||||
|
||||
@@ -3023,6 +3023,13 @@ Tcl_DeleteCommandFromToken(
|
||||
ImportRef *refPtr, *nextRefPtr;
|
||||
Tcl_Command importCmd;
|
||||
|
||||
/*
|
||||
* Bump the command epoch counter. This will invalidate all cached
|
||||
* references that point to this command.
|
||||
*/
|
||||
|
||||
cmdPtr->cmdEpoch++;
|
||||
|
||||
/*
|
||||
* The code here is tricky. We can't delete the hash table entry before
|
||||
* invoking the deletion callback because there are cases where the
|
||||
@@ -3045,14 +3052,6 @@ Tcl_DeleteCommandFromToken(
|
||||
Tcl_DeleteHashEntry(cmdPtr->hPtr);
|
||||
cmdPtr->hPtr = NULL;
|
||||
}
|
||||
|
||||
/*
|
||||
* Bump the command epoch counter. This will invalidate all cached
|
||||
* references that point to this command.
|
||||
*/
|
||||
|
||||
cmdPtr->cmdEpoch++;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -3155,13 +3154,6 @@ Tcl_DeleteCommandFromToken(
|
||||
if (cmdPtr->hPtr != NULL) {
|
||||
Tcl_DeleteHashEntry(cmdPtr->hPtr);
|
||||
cmdPtr->hPtr = NULL;
|
||||
|
||||
/*
|
||||
* Bump the command epoch counter. This will invalidate all cached
|
||||
* references that point to this command.
|
||||
*/
|
||||
|
||||
cmdPtr->cmdEpoch++;
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -3408,7 +3400,8 @@ TclCleanupCommand(
|
||||
register Command *cmdPtr) /* Points to the Command structure to
|
||||
* be freed. */
|
||||
{
|
||||
if (cmdPtr->refCount-- <= 1) {
|
||||
cmdPtr->refCount--;
|
||||
if (cmdPtr->refCount <= 0) {
|
||||
ckfree(cmdPtr);
|
||||
}
|
||||
}
|
||||
@@ -3530,7 +3523,7 @@ OldMathFuncProc(
|
||||
Tcl_SetObjResult(interp, Tcl_NewStringObj(
|
||||
"argument to math function didn't have numeric value",
|
||||
-1));
|
||||
TclCheckBadOctal(interp, TclGetString(valuePtr));
|
||||
TclCheckBadOctal(interp, Tcl_GetString(valuePtr));
|
||||
ckfree(args);
|
||||
return TCL_ERROR;
|
||||
}
|
||||
@@ -5585,7 +5578,8 @@ TclArgumentRelease(
|
||||
}
|
||||
cfwPtr = Tcl_GetHashValue(hPtr);
|
||||
|
||||
if (cfwPtr->refCount-- > 1) {
|
||||
cfwPtr->refCount--;
|
||||
if (cfwPtr->refCount > 0) {
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -7890,7 +7884,7 @@ MathFuncWrongNumArgs(
|
||||
int found, /* Actual parameter count. */
|
||||
Tcl_Obj *const *objv) /* Actual parameter vector. */
|
||||
{
|
||||
const char *name = TclGetString(objv[0]);
|
||||
const char *name = Tcl_GetString(objv[0]);
|
||||
const char *tail = name + strlen(name);
|
||||
|
||||
while (tail > name+1) {
|
||||
@@ -8823,7 +8817,7 @@ TclNRInterpCoroutine(
|
||||
if (!COR_IS_SUSPENDED(corPtr)) {
|
||||
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
|
||||
"coroutine \"%s\" is already running",
|
||||
TclGetString(objv[0])));
|
||||
Tcl_GetString(objv[0])));
|
||||
Tcl_SetErrorCode(interp, "TCL", "COROUTINE", "BUSY", NULL);
|
||||
return TCL_ERROR;
|
||||
}
|
||||
|
||||
+43
-133
@@ -155,108 +155,35 @@ static const EnsembleImplMap decodeMap[] = {
|
||||
};
|
||||
|
||||
/*
|
||||
* The following object types represent an array of bytes. The intent is
|
||||
* to allow arbitrary binary data to pass through Tcl as a Tcl value
|
||||
* without loss or damage. Such values are useful for things like
|
||||
* encoded strings or Tk images to name just two.
|
||||
* The following object type represents an array of bytes. An array of bytes
|
||||
* is not equivalent to an internationalized string. Conceptually, a string is
|
||||
* an array of 16-bit quantities organized as a sequence of properly formed
|
||||
* UTF-8 characters, while a ByteArray is an array of 8-bit quantities.
|
||||
* Accessor functions are provided to convert a ByteArray to a String or a
|
||||
* String to a ByteArray. Two or more consecutive bytes in an array of bytes
|
||||
* may look like a single UTF-8 character if the array is casually treated as
|
||||
* a string. But obtaining the String from a ByteArray is guaranteed to
|
||||
* produced properly formed UTF-8 sequences so that there is a one-to-one map
|
||||
* between bytes and characters.
|
||||
*
|
||||
* It's strange to have two Tcl_ObjTypes in place for this task when
|
||||
* one would do, so a bit of detail and history how we got to this point
|
||||
* and where we might go from here.
|
||||
* Converting a ByteArray to a String proceeds by casting each byte in the
|
||||
* array to a 16-bit quantity, treating that number as a Unicode character,
|
||||
* and storing the UTF-8 version of that Unicode character in the String. For
|
||||
* ByteArrays consisting entirely of values 1..127, the corresponding String
|
||||
* representation is the same as the ByteArray representation.
|
||||
*
|
||||
* A bytearray is an ordered sequence of bytes. Each byte is an integer
|
||||
* value in the range [0-255]. To be a Tcl value type, we need a way to
|
||||
* encode each value in the value set as a Tcl string. The simplest
|
||||
* encoding is to represent each byte value as the same codepoint value.
|
||||
* A bytearray of N bytes is encoded into a Tcl string of N characters
|
||||
* where the codepoint of each character is the value of corresponding byte.
|
||||
* This approach creates a one-to-one map between all bytearray values
|
||||
* and a subset of Tcl string values.
|
||||
*
|
||||
* When converting a Tcl string value to the bytearray internal rep, the
|
||||
* question arises what to do with strings outside that subset? That is,
|
||||
* those Tcl strings containing at least one codepoint greater than 255?
|
||||
* The obviously correct answer is to raise an error! That string value
|
||||
* does not represent any valid bytearray value. Full Stop. The
|
||||
* setFromAnyProc signature has a completion code return value for just
|
||||
* this reason, to reject invalid inputs.
|
||||
*
|
||||
* Unfortunately this was not the path taken by the authors of the
|
||||
* original tclByteArrayType. They chose to accept all Tcl string values
|
||||
* as acceptable string encodings of the bytearray values that result
|
||||
* from masking away the high bits of any codepoint value at all. This
|
||||
* meant that every bytearray value had multiple accepted string
|
||||
* representations.
|
||||
*
|
||||
* The implications of this choice are truly ugly. When a Tcl value has
|
||||
* a string representation, we are required to accept that as the true
|
||||
* value. Bytearray values that possess a string representation cannot
|
||||
* be processed as bytearrays because we cannot know which true value
|
||||
* that bytearray represents. The consequence is that we drag around
|
||||
* an internal rep that we cannot make any use of. This painful price
|
||||
* is extracted at any point after a string rep happens to be generated
|
||||
* for the value. This happens even when the troublesome codepoints
|
||||
* outside the byte range never show up. This happens rather routinely
|
||||
* in normal Tcl operations unless we burden the script writer with the
|
||||
* cognitive burden of avoiding it. The price is also paid by callers
|
||||
* of the C interface. The routine
|
||||
*
|
||||
* unsigned char *Tcl_GetByteArrayFromObj(objPtr, lenPtr)
|
||||
*
|
||||
* has a guarantee to always return a non-NULL value, but that value
|
||||
* points to a byte sequence that cannot be used by the caller to
|
||||
* process the Tcl value absent some sideband testing that objPtr
|
||||
* is "pure". Tcl offers no public interface to perform this test,
|
||||
* so callers either break encapsulation or are unavoidably buggy. Tcl
|
||||
* has defined a public interface that cannot be used correctly. The
|
||||
* Tcl source code itself suffers the same problem, and has been buggy,
|
||||
* but progressively less so as more and more portions of the code have
|
||||
* been retrofitted with the required "purity testing". The set of values
|
||||
* able to pass the purity test can be increased via the introduction of
|
||||
* a "canonical" flag marker, but the only way the broken interface itself
|
||||
* can be discarded is to start over and define the Tcl_ObjType properly.
|
||||
* Bytearrays should simply be usable as bytearrays without a kabuki
|
||||
* dance of testing.
|
||||
*
|
||||
* The Tcl_ObjType "properByteArrayType" is (nearly) a correct
|
||||
* implementation of bytearrays. Any Tcl value with the type
|
||||
* properByteArrayType can have its bytearray value fetched and
|
||||
* used with confidence that acting on that value is equivalent to
|
||||
* acting on the true Tcl string value. This still implies a side
|
||||
* testing burden -- past mistakes will not let us avoid that
|
||||
* immediately, but it is at least a conventional test of type, and
|
||||
* can be implemented entirely by examining the objPtr fields, with
|
||||
* no need to query the intrep, as a canonical flag would require.
|
||||
*
|
||||
* Until Tcl_GetByteArrayFromObj() and Tcl_SetByteArrayLength() can
|
||||
* be revised to admit the possibility of returning NULL when the true
|
||||
* value is not a valid bytearray, we need a mechanism to retain
|
||||
* compatibility with the deployed callers of the broken interface.
|
||||
* That's what the retained "tclByteArrayType" provides. In those
|
||||
* unusual circumstances where we convert an invalid bytearray value
|
||||
* to a bytearray type, it is to this legacy type. Essentially any
|
||||
* time this legacy type gets used, it's a signal of a bug being ignored.
|
||||
* A TIP should be drafted to remove this connection to the broken past
|
||||
* so that Tcl 9 will no longer have any trace of it. Prescribing a
|
||||
* migration path will be the key element of that work. The internal
|
||||
* changes now in place are the limit of what can be done short of
|
||||
* interface repair. They provide a great expansion of the histories
|
||||
* over which bytearray values can be useful in the meanwhile.
|
||||
* Converting a String to a ByteArray proceeds by getting the Unicode
|
||||
* representation of each character in the String, casting it to a byte by
|
||||
* truncating the upper 8 bits, and then storing the byte in the ByteArray.
|
||||
* Converting from ByteArray to String and back to ByteArray is not lossy, but
|
||||
* converting an arbitrary String to a ByteArray may be.
|
||||
*/
|
||||
|
||||
static const Tcl_ObjType properByteArrayType = {
|
||||
"bytearray",
|
||||
FreeByteArrayInternalRep,
|
||||
DupByteArrayInternalRep,
|
||||
UpdateStringOfByteArray,
|
||||
NULL
|
||||
};
|
||||
|
||||
const Tcl_ObjType tclByteArrayType = {
|
||||
"bytearray",
|
||||
FreeByteArrayInternalRep,
|
||||
DupByteArrayInternalRep,
|
||||
NULL,
|
||||
UpdateStringOfByteArray,
|
||||
SetByteArrayFromAny
|
||||
};
|
||||
|
||||
@@ -284,12 +211,6 @@ typedef struct ByteArray {
|
||||
#define SET_BYTEARRAY(objPtr, baPtr) \
|
||||
(objPtr)->internalRep.twoPtrValue.ptr1 = (void *) (baPtr)
|
||||
|
||||
int
|
||||
TclIsPureByteArray(
|
||||
Tcl_Obj * objPtr)
|
||||
{
|
||||
return (objPtr->typePtr == &properByteArrayType);
|
||||
}
|
||||
|
||||
/*
|
||||
*----------------------------------------------------------------------
|
||||
@@ -420,7 +341,7 @@ Tcl_SetByteArrayObj(
|
||||
if ((bytes != NULL) && (length > 0)) {
|
||||
memcpy(byteArrayPtr->bytes, bytes, (size_t) length);
|
||||
}
|
||||
objPtr->typePtr = &properByteArrayType;
|
||||
objPtr->typePtr = &tclByteArrayType;
|
||||
SET_BYTEARRAY(objPtr, byteArrayPtr);
|
||||
}
|
||||
|
||||
@@ -450,8 +371,7 @@ Tcl_GetByteArrayFromObj(
|
||||
{
|
||||
ByteArray *baPtr;
|
||||
|
||||
if ((objPtr->typePtr != &properByteArrayType)
|
||||
&& (objPtr->typePtr != &tclByteArrayType)) {
|
||||
if (objPtr->typePtr != &tclByteArrayType) {
|
||||
SetByteArrayFromAny(NULL, objPtr);
|
||||
}
|
||||
baPtr = GET_BYTEARRAY(objPtr);
|
||||
@@ -494,8 +414,7 @@ Tcl_SetByteArrayLength(
|
||||
if (Tcl_IsShared(objPtr)) {
|
||||
Tcl_Panic("%s called with shared object", "Tcl_SetByteArrayLength");
|
||||
}
|
||||
if ((objPtr->typePtr != &properByteArrayType)
|
||||
&& (objPtr->typePtr != &tclByteArrayType)) {
|
||||
if (objPtr->typePtr != &tclByteArrayType) {
|
||||
SetByteArrayFromAny(NULL, objPtr);
|
||||
}
|
||||
|
||||
@@ -531,37 +450,29 @@ SetByteArrayFromAny(
|
||||
Tcl_Interp *interp, /* Not used. */
|
||||
Tcl_Obj *objPtr) /* The object to convert to type ByteArray. */
|
||||
{
|
||||
size_t length;
|
||||
int improper = 0;
|
||||
int length;
|
||||
const char *src, *srcEnd;
|
||||
unsigned char *dst;
|
||||
ByteArray *byteArrayPtr;
|
||||
Tcl_UniChar ch;
|
||||
|
||||
if (objPtr->typePtr == &properByteArrayType) {
|
||||
return TCL_OK;
|
||||
if (objPtr->typePtr != &tclByteArrayType) {
|
||||
src = TclGetStringFromObj(objPtr, &length);
|
||||
srcEnd = src + length;
|
||||
|
||||
byteArrayPtr = ckalloc(BYTEARRAY_SIZE(length));
|
||||
for (dst = byteArrayPtr->bytes; src < srcEnd; ) {
|
||||
src += Tcl_UtfToUniChar(src, &ch);
|
||||
*dst++ = UCHAR(ch);
|
||||
}
|
||||
|
||||
byteArrayPtr->used = dst - byteArrayPtr->bytes;
|
||||
byteArrayPtr->allocated = length;
|
||||
|
||||
TclFreeIntRep(objPtr);
|
||||
objPtr->typePtr = &tclByteArrayType;
|
||||
SET_BYTEARRAY(objPtr, byteArrayPtr);
|
||||
}
|
||||
if (objPtr->typePtr == &tclByteArrayType) {
|
||||
return TCL_OK;
|
||||
}
|
||||
|
||||
src = TclGetString(objPtr);
|
||||
length = objPtr->length;
|
||||
srcEnd = src + length;
|
||||
|
||||
byteArrayPtr = ckalloc(BYTEARRAY_SIZE(length));
|
||||
for (dst = byteArrayPtr->bytes; src < srcEnd; ) {
|
||||
src += Tcl_UtfToUniChar(src, &ch);
|
||||
improper = improper || (ch > 255);
|
||||
*dst++ = UCHAR(ch);
|
||||
}
|
||||
|
||||
byteArrayPtr->used = dst - byteArrayPtr->bytes;
|
||||
byteArrayPtr->allocated = length;
|
||||
|
||||
TclFreeIntRep(objPtr);
|
||||
objPtr->typePtr = improper ? &tclByteArrayType : &properByteArrayType;
|
||||
SET_BYTEARRAY(objPtr, byteArrayPtr);
|
||||
return TCL_OK;
|
||||
}
|
||||
|
||||
@@ -624,7 +535,7 @@ DupByteArrayInternalRep(
|
||||
memcpy(copyArrayPtr->bytes, srcArrayPtr->bytes, (size_t) length);
|
||||
SET_BYTEARRAY(copyPtr, copyArrayPtr);
|
||||
|
||||
copyPtr->typePtr = srcPtr->typePtr;
|
||||
copyPtr->typePtr = &tclByteArrayType;
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -731,8 +642,7 @@ TclAppendBytesToByteArray(
|
||||
/* Append zero bytes is a no-op. */
|
||||
return;
|
||||
}
|
||||
if ((objPtr->typePtr != &properByteArrayType)
|
||||
&& (objPtr->typePtr != &tclByteArrayType)) {
|
||||
if (objPtr->typePtr != &tclByteArrayType) {
|
||||
SetByteArrayFromAny(NULL, objPtr);
|
||||
}
|
||||
byteArrayPtr = GET_BYTEARRAY(objPtr);
|
||||
|
||||
+28
-27
@@ -34,14 +34,14 @@
|
||||
*/
|
||||
|
||||
typedef struct MemTag {
|
||||
size_t refCount; /* Number of mem_headers referencing this
|
||||
int refCount; /* Number of mem_headers referencing this
|
||||
* tag. */
|
||||
char string[1]; /* Actual size of string will be as large as
|
||||
* needed for actual tag. This must be the
|
||||
* last field in the structure. */
|
||||
} MemTag;
|
||||
|
||||
#define TAG_SIZE(bytesInString) ((TclOffset(MemTag, string) + 1) + bytesInString)
|
||||
#define TAG_SIZE(bytesInString) ((unsigned) ((TclOffset(MemTag, string) + 1) + bytesInString))
|
||||
|
||||
static MemTag *curTagPtr = NULL;/* Tag to use in all future mem_headers (set
|
||||
* by "memory tag" command). */
|
||||
@@ -52,14 +52,14 @@ static MemTag *curTagPtr = NULL;/* Tag to use in all future mem_headers (set
|
||||
* to help detect chunk under-runs.
|
||||
*/
|
||||
|
||||
#define LOW_GUARD_SIZE (8 + (32 - (sizeof(size_t) + sizeof(int)))%8)
|
||||
#define LOW_GUARD_SIZE (8 + (32 - (sizeof(long) + sizeof(int)))%8)
|
||||
struct mem_header {
|
||||
struct mem_header *flink;
|
||||
struct mem_header *blink;
|
||||
MemTag *tagPtr; /* Tag from "memory tag" command; may be
|
||||
* NULL. */
|
||||
const char *file;
|
||||
size_t length;
|
||||
long length;
|
||||
int line;
|
||||
unsigned char low_guard[LOW_GUARD_SIZE];
|
||||
/* Aligns body on 8-byte boundary, plus
|
||||
@@ -251,10 +251,10 @@ ValidateMemory(
|
||||
}
|
||||
if (guard_failed) {
|
||||
TclDumpMemoryInfo((ClientData) stderr, 0);
|
||||
fprintf(stderr, "low guard failed at %p, %s %d\n",
|
||||
memHeaderP->body, file, line);
|
||||
fprintf(stderr, "low guard failed at %lx, %s %d\n",
|
||||
(long unsigned) memHeaderP->body, file, line);
|
||||
fflush(stderr); /* In case name pointer is bad. */
|
||||
fprintf(stderr, "%" TCL_LL_MODIFIER "d bytes allocated at (%s %d)\n", (Tcl_WideInt) memHeaderP->length,
|
||||
fprintf(stderr, "%ld bytes allocated at (%s %d)\n", memHeaderP->length,
|
||||
memHeaderP->file, memHeaderP->line);
|
||||
Tcl_Panic("Memory validation failure");
|
||||
}
|
||||
@@ -273,11 +273,11 @@ ValidateMemory(
|
||||
|
||||
if (guard_failed) {
|
||||
TclDumpMemoryInfo((ClientData) stderr, 0);
|
||||
fprintf(stderr, "high guard failed at %p, %s %d\n",
|
||||
memHeaderP->body, file, line);
|
||||
fprintf(stderr, "high guard failed at %lx, %s %d\n",
|
||||
(long unsigned) memHeaderP->body, file, line);
|
||||
fflush(stderr); /* In case name pointer is bad. */
|
||||
fprintf(stderr, "%" TCL_LL_MODIFIER "d bytes allocated at (%s %d)\n",
|
||||
(Tcl_WideInt)memHeaderP->length, memHeaderP->file,
|
||||
fprintf(stderr, "%ld bytes allocated at (%s %d)\n",
|
||||
memHeaderP->length, memHeaderP->file,
|
||||
memHeaderP->line);
|
||||
Tcl_Panic("Memory validation failure");
|
||||
}
|
||||
@@ -359,10 +359,10 @@ Tcl_DumpActiveMemory(
|
||||
Tcl_MutexLock(ckallocMutexPtr);
|
||||
for (memScanP = allocHead; memScanP != NULL; memScanP = memScanP->flink) {
|
||||
address = &memScanP->body[0];
|
||||
fprintf(fileP, "%8" TCL_LL_MODIFIER "x - %8" TCL_LL_MODIFIER "x %7" TCL_LL_MODIFIER "d @ %s %d %s",
|
||||
(Tcl_WideInt)(size_t)address,
|
||||
(Tcl_WideInt)((size_t)address + memScanP->length - 1),
|
||||
(Tcl_WideInt)memScanP->length, memScanP->file, memScanP->line,
|
||||
fprintf(fileP, "%8lx - %8lx %7ld @ %s %d %s",
|
||||
(long unsigned) address,
|
||||
(long unsigned) address + memScanP->length - 1,
|
||||
memScanP->length, memScanP->file, memScanP->line,
|
||||
(memScanP->tagPtr == NULL) ? "" : memScanP->tagPtr->string);
|
||||
(void) fputc('\n', fileP);
|
||||
}
|
||||
@@ -458,8 +458,8 @@ Tcl_DbCkalloc(
|
||||
}
|
||||
|
||||
if (alloc_tracing) {
|
||||
fprintf(stderr,"ckalloc %p %u %s %d\n",
|
||||
result->body, size, file, line);
|
||||
fprintf(stderr,"ckalloc %lx %u %s %d\n",
|
||||
(long unsigned int) result->body, size, file, line);
|
||||
}
|
||||
|
||||
if (break_on_malloc && (total_mallocs >= break_on_malloc)) {
|
||||
@@ -547,8 +547,8 @@ Tcl_AttemptDbCkalloc(
|
||||
}
|
||||
|
||||
if (alloc_tracing) {
|
||||
fprintf(stderr,"ckalloc %p %u %s %d\n",
|
||||
result->body, size, file, line);
|
||||
fprintf(stderr,"ckalloc %lx %u %s %d\n",
|
||||
(long unsigned int) result->body, size, file, line);
|
||||
}
|
||||
|
||||
if (break_on_malloc && (total_mallocs >= break_on_malloc)) {
|
||||
@@ -612,8 +612,8 @@ Tcl_DbCkfree(
|
||||
memp = (struct mem_header *) (((size_t) ptr) - BODY_OFFSET);
|
||||
|
||||
if (alloc_tracing) {
|
||||
fprintf(stderr, "ckfree %p %" TCL_LL_MODIFIER "d %s %d\n",
|
||||
memp->body, (Tcl_WideInt) memp->length, file, line);
|
||||
fprintf(stderr, "ckfree %lx %ld %s %d\n",
|
||||
(long unsigned int) memp->body, memp->length, file, line);
|
||||
}
|
||||
|
||||
if (validate_memory) {
|
||||
@@ -623,7 +623,7 @@ Tcl_DbCkfree(
|
||||
Tcl_MutexLock(ckallocMutexPtr);
|
||||
ValidateMemory(memp, file, line, TRUE);
|
||||
if (init_malloced_bodies) {
|
||||
memset(ptr, GUARD_VALUE, memp->length);
|
||||
memset(ptr, GUARD_VALUE, (size_t) memp->length);
|
||||
}
|
||||
|
||||
total_frees++;
|
||||
@@ -631,7 +631,8 @@ Tcl_DbCkfree(
|
||||
current_bytes_malloced -= memp->length;
|
||||
|
||||
if (memp->tagPtr != NULL) {
|
||||
if ((memp->tagPtr->refCount-- <= 1) && (curTagPtr != memp->tagPtr)) {
|
||||
memp->tagPtr->refCount--;
|
||||
if ((memp->tagPtr->refCount == 0) && (curTagPtr != memp->tagPtr)) {
|
||||
TclpFree((char *) memp->tagPtr);
|
||||
}
|
||||
}
|
||||
@@ -674,7 +675,7 @@ Tcl_DbCkrealloc(
|
||||
int line)
|
||||
{
|
||||
char *newPtr;
|
||||
size_t copySize;
|
||||
unsigned int copySize;
|
||||
struct mem_header *memp;
|
||||
|
||||
if (ptr == NULL) {
|
||||
@@ -688,7 +689,7 @@ Tcl_DbCkrealloc(
|
||||
memp = (struct mem_header *) (((size_t) ptr) - BODY_OFFSET);
|
||||
|
||||
copySize = size;
|
||||
if (copySize > memp->length) {
|
||||
if (copySize > (unsigned int) memp->length) {
|
||||
copySize = memp->length;
|
||||
}
|
||||
newPtr = Tcl_DbCkalloc(size, file, line);
|
||||
@@ -705,7 +706,7 @@ Tcl_AttemptDbCkrealloc(
|
||||
int line)
|
||||
{
|
||||
char *newPtr;
|
||||
size_t copySize;
|
||||
unsigned int copySize;
|
||||
struct mem_header *memp;
|
||||
|
||||
if (ptr == NULL) {
|
||||
@@ -719,7 +720,7 @@ Tcl_AttemptDbCkrealloc(
|
||||
memp = (struct mem_header *) (((size_t) ptr) - BODY_OFFSET);
|
||||
|
||||
copySize = size;
|
||||
if (copySize > memp->length) {
|
||||
if (copySize > (unsigned int) memp->length) {
|
||||
copySize = memp->length;
|
||||
}
|
||||
newPtr = Tcl_AttemptDbCkalloc(size, file, line);
|
||||
|
||||
+3
-2
@@ -92,7 +92,7 @@ static const char *const literals[] = {
|
||||
*/
|
||||
|
||||
typedef struct ClockClientData {
|
||||
size_t refCount; /* Number of live references. */
|
||||
int refCount; /* Number of live references. */
|
||||
Tcl_Obj **literals; /* Pool of object literals. */
|
||||
} ClockClientData;
|
||||
|
||||
@@ -2060,7 +2060,8 @@ ClockDeleteCmdProc(
|
||||
ClockClientData *data = clientData;
|
||||
int i;
|
||||
|
||||
if (data->refCount-- <= 1) {
|
||||
data->refCount--;
|
||||
if (data->refCount == 0) {
|
||||
for (i = 0; i < LIT__END; ++i) {
|
||||
Tcl_DecrRefCount(data->literals[i]);
|
||||
}
|
||||
|
||||
+1
-1
@@ -1597,7 +1597,7 @@ FileAttrIsOwnedCmd(
|
||||
Tcl_Obj *const objv[])
|
||||
{
|
||||
#ifdef __CYGWIN__
|
||||
#define geteuid() (short)(geteuid)()
|
||||
#define geteuid() (short)(geteuid)()
|
||||
#endif
|
||||
#if !defined(_WIN32)
|
||||
Tcl_StatBuf buf;
|
||||
|
||||
+9
-37
@@ -2155,8 +2155,8 @@ Tcl_JoinObjCmd(
|
||||
int objc, /* Number of arguments. */
|
||||
Tcl_Obj *const objv[]) /* The argument objects. */
|
||||
{
|
||||
int listLen;
|
||||
Tcl_Obj *resObjPtr = NULL, *joinObjPtr, **elemPtrs;
|
||||
int listLen, i;
|
||||
Tcl_Obj *resObjPtr, *joinObjPtr, **elemPtrs;
|
||||
|
||||
if ((objc < 2) || (objc > 3)) {
|
||||
Tcl_WrongNumArgs(interp, 1, objv, "list ?joinString?");
|
||||
@@ -2173,47 +2173,19 @@ Tcl_JoinObjCmd(
|
||||
return TCL_ERROR;
|
||||
}
|
||||
|
||||
if (listLen == 0) {
|
||||
/* No elements to join; default empty result is correct. */
|
||||
return TCL_OK;
|
||||
}
|
||||
if (listLen == 1) {
|
||||
/* One element; return it */
|
||||
Tcl_SetObjResult(interp, elemPtrs[0]);
|
||||
return TCL_OK;
|
||||
}
|
||||
|
||||
joinObjPtr = (objc == 2) ? Tcl_NewStringObj(" ", 1) : objv[2];
|
||||
Tcl_IncrRefCount(joinObjPtr);
|
||||
|
||||
if (Tcl_GetCharLength(joinObjPtr) == 0) {
|
||||
TclStringCatObjv(interp, /* inPlace */ 0, listLen, elemPtrs,
|
||||
&resObjPtr);
|
||||
} else {
|
||||
int i;
|
||||
|
||||
resObjPtr = Tcl_NewObj();
|
||||
for (i = 0; i < listLen; i++) {
|
||||
if (i > 0) {
|
||||
|
||||
/*
|
||||
* NOTE: This code is relying on Tcl_AppendObjToObj() **NOT**
|
||||
* to shimmer joinObjPtr. If it did, then the case where
|
||||
* objv[1] and objv[2] are the same value would not be safe.
|
||||
* Accessing elemPtrs would crash.
|
||||
*/
|
||||
|
||||
Tcl_AppendObjToObj(resObjPtr, joinObjPtr);
|
||||
}
|
||||
Tcl_AppendObjToObj(resObjPtr, elemPtrs[i]);
|
||||
resObjPtr = Tcl_NewObj();
|
||||
for (i = 0; i < listLen; i++) {
|
||||
if (i > 0) {
|
||||
Tcl_AppendObjToObj(resObjPtr, joinObjPtr);
|
||||
}
|
||||
Tcl_AppendObjToObj(resObjPtr, elemPtrs[i]);
|
||||
}
|
||||
Tcl_DecrRefCount(joinObjPtr);
|
||||
if (resObjPtr) {
|
||||
Tcl_SetObjResult(interp, resObjPtr);
|
||||
return TCL_OK;
|
||||
}
|
||||
return TCL_ERROR;
|
||||
Tcl_SetObjResult(interp, resObjPtr);
|
||||
return TCL_OK;
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
+200
-38
@@ -323,7 +323,7 @@ Tcl_RegexpObjCmd(
|
||||
|
||||
if (match == 0) {
|
||||
/*
|
||||
* We want to set the value of the interpreter result only when
|
||||
* We want to set the value of the intepreter result only when
|
||||
* this is the first time through the loop.
|
||||
*/
|
||||
|
||||
@@ -1176,7 +1176,8 @@ StringFirstCmd(
|
||||
int objc, /* Number of arguments. */
|
||||
Tcl_Obj *const objv[]) /* Argument objects. */
|
||||
{
|
||||
int start = 0;
|
||||
Tcl_UniChar *needleStr, *haystackStr;
|
||||
int match, start, needleLen, haystackLen;
|
||||
|
||||
if (objc < 3 || objc > 4) {
|
||||
Tcl_WrongNumArgs(interp, 1, objv,
|
||||
@@ -1184,23 +1185,82 @@ StringFirstCmd(
|
||||
return TCL_ERROR;
|
||||
}
|
||||
|
||||
if (objc == 4) {
|
||||
int size = Tcl_GetCharLength(objv[2]);
|
||||
/*
|
||||
* We are searching haystackStr for the sequence needleStr.
|
||||
*/
|
||||
|
||||
if (TCL_OK != TclGetIntForIndexM(interp, objv[3], size - 1, &start)) {
|
||||
match = -1;
|
||||
start = 0;
|
||||
haystackLen = -1;
|
||||
|
||||
needleStr = Tcl_GetUnicodeFromObj(objv[1], &needleLen);
|
||||
haystackStr = Tcl_GetUnicodeFromObj(objv[2], &haystackLen);
|
||||
|
||||
if (objc == 4) {
|
||||
/*
|
||||
* If a startIndex is specified, we will need to fast forward to that
|
||||
* point in the string before we think about a match.
|
||||
*/
|
||||
|
||||
if (TclGetIntForIndexM(interp, objv[3], haystackLen-1,
|
||||
&start) != TCL_OK){
|
||||
return TCL_ERROR;
|
||||
}
|
||||
|
||||
if (start < 0) {
|
||||
/*
|
||||
* Reread to prevent shimmering problems.
|
||||
*/
|
||||
|
||||
needleStr = Tcl_GetUnicodeFromObj(objv[1], &needleLen);
|
||||
haystackStr = Tcl_GetUnicodeFromObj(objv[2], &haystackLen);
|
||||
|
||||
if (start >= haystackLen) {
|
||||
goto str_first_done;
|
||||
} else if (start > 0) {
|
||||
haystackStr += start;
|
||||
haystackLen -= start;
|
||||
} else if (start < 0) {
|
||||
/*
|
||||
* Invalid start index mapped to string start; Bug #423581
|
||||
*/
|
||||
|
||||
start = 0;
|
||||
}
|
||||
if (start >= size) {
|
||||
Tcl_SetObjResult(interp, Tcl_NewIntObj(-1));
|
||||
return TCL_OK;
|
||||
}
|
||||
|
||||
/*
|
||||
* If the length of the needle is more than the length of the haystack, it
|
||||
* cannot be contained in there so we can avoid searching. [Bug 2960021]
|
||||
*/
|
||||
|
||||
if (needleLen > 0 && needleLen <= haystackLen) {
|
||||
register Tcl_UniChar *p, *end;
|
||||
|
||||
end = haystackStr + haystackLen - needleLen + 1;
|
||||
for (p = haystackStr; p < end; p++) {
|
||||
/*
|
||||
* Scan forward to find the first character.
|
||||
*/
|
||||
|
||||
if ((*p == *needleStr) && (TclUniCharNcmp(needleStr, p,
|
||||
(unsigned long) needleLen) == 0)) {
|
||||
match = p - haystackStr;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
Tcl_SetObjResult(interp, Tcl_NewIntObj(TclStringFind(objv[1],
|
||||
objv[2], start)));
|
||||
|
||||
/*
|
||||
* Compute the character index of the matching string by counting the
|
||||
* number of characters before the match.
|
||||
*/
|
||||
|
||||
if ((match != -1) && (objc == 4)) {
|
||||
match += start;
|
||||
}
|
||||
|
||||
str_first_done:
|
||||
Tcl_SetObjResult(interp, Tcl_NewIntObj(match));
|
||||
return TCL_OK;
|
||||
}
|
||||
|
||||
@@ -1229,31 +1289,76 @@ StringLastCmd(
|
||||
int objc, /* Number of arguments. */
|
||||
Tcl_Obj *const objv[]) /* Argument objects. */
|
||||
{
|
||||
int last = INT_MAX - 1;
|
||||
Tcl_UniChar *needleStr, *haystackStr, *p;
|
||||
int match, start, needleLen, haystackLen;
|
||||
|
||||
if (objc < 3 || objc > 4) {
|
||||
Tcl_WrongNumArgs(interp, 1, objv,
|
||||
"needleString haystackString ?lastIndex?");
|
||||
"needleString haystackString ?startIndex?");
|
||||
return TCL_ERROR;
|
||||
}
|
||||
|
||||
if (objc == 4) {
|
||||
int size = Tcl_GetCharLength(objv[2]);
|
||||
/*
|
||||
* We are searching haystackString for the sequence needleString.
|
||||
*/
|
||||
|
||||
if (TCL_OK != TclGetIntForIndexM(interp, objv[3], size - 1, &last)) {
|
||||
match = -1;
|
||||
start = 0;
|
||||
haystackLen = -1;
|
||||
|
||||
needleStr = Tcl_GetUnicodeFromObj(objv[1], &needleLen);
|
||||
haystackStr = Tcl_GetUnicodeFromObj(objv[2], &haystackLen);
|
||||
|
||||
if (objc == 4) {
|
||||
/*
|
||||
* If a startIndex is specified, we will need to restrict the string
|
||||
* range to that char index in the string
|
||||
*/
|
||||
|
||||
if (TclGetIntForIndexM(interp, objv[3], haystackLen-1,
|
||||
&start) != TCL_OK){
|
||||
return TCL_ERROR;
|
||||
}
|
||||
|
||||
if (last < 0) {
|
||||
Tcl_SetObjResult(interp, Tcl_NewIntObj(-1));
|
||||
return TCL_OK;
|
||||
/*
|
||||
* Reread to prevent shimmering problems.
|
||||
*/
|
||||
|
||||
needleStr = Tcl_GetUnicodeFromObj(objv[1], &needleLen);
|
||||
haystackStr = Tcl_GetUnicodeFromObj(objv[2], &haystackLen);
|
||||
|
||||
if (start < 0) {
|
||||
goto str_last_done;
|
||||
} else if (start < haystackLen) {
|
||||
p = haystackStr + start + 1 - needleLen;
|
||||
} else {
|
||||
p = haystackStr + haystackLen - needleLen;
|
||||
}
|
||||
if (last >= size) {
|
||||
last = size - 1;
|
||||
} else {
|
||||
p = haystackStr + haystackLen - needleLen;
|
||||
}
|
||||
|
||||
/*
|
||||
* If the length of the needle is more than the length of the haystack, it
|
||||
* cannot be contained in there so we can avoid searching. [Bug 2960021]
|
||||
*/
|
||||
|
||||
if (needleLen > 0 && needleLen <= haystackLen) {
|
||||
for (; p >= haystackStr; p--) {
|
||||
/*
|
||||
* Scan backwards to find the first character.
|
||||
*/
|
||||
|
||||
if ((*p == *needleStr) && !memcmp(needleStr, p,
|
||||
sizeof(Tcl_UniChar) * (size_t)needleLen)) {
|
||||
match = p - haystackStr;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
Tcl_SetObjResult(interp, Tcl_NewIntObj(TclStringLast(objv[1],
|
||||
objv[2], last)));
|
||||
|
||||
str_last_done:
|
||||
Tcl_SetObjResult(interp, Tcl_NewIntObj(match));
|
||||
return TCL_OK;
|
||||
}
|
||||
|
||||
@@ -1768,7 +1873,7 @@ StringMapCmd(
|
||||
|
||||
/*
|
||||
* This test is tricky, but has to be that way or you get other strange
|
||||
* inconsistencies (see test string-10.20.1 for illustration why!)
|
||||
* inconsistencies (see test string-10.20 for illustration why!)
|
||||
*/
|
||||
|
||||
if (objv[objc-2]->typePtr == &tclDictType && objv[objc-2]->bytes == NULL){
|
||||
@@ -2118,7 +2223,9 @@ StringReptCmd(
|
||||
int objc, /* Number of arguments. */
|
||||
Tcl_Obj *const objv[]) /* Argument objects. */
|
||||
{
|
||||
int count;
|
||||
const char *string1;
|
||||
char *string2;
|
||||
int count, index, length1, length2;
|
||||
Tcl_Obj *resultPtr;
|
||||
|
||||
if (objc != 3) {
|
||||
@@ -2136,15 +2243,70 @@ StringReptCmd(
|
||||
|
||||
if (count == 1) {
|
||||
Tcl_SetObjResult(interp, objv[1]);
|
||||
return TCL_OK;
|
||||
goto done;
|
||||
} else if (count < 1) {
|
||||
return TCL_OK;
|
||||
goto done;
|
||||
}
|
||||
string1 = TclGetStringFromObj(objv[1], &length1);
|
||||
if (length1 <= 0) {
|
||||
goto done;
|
||||
}
|
||||
|
||||
if (TCL_OK != TclStringRepeat(interp, objv[1], count, &resultPtr)) {
|
||||
/*
|
||||
* Only build up a string that has data. Instead of building it up with
|
||||
* repeated appends, we just allocate the necessary space once and copy
|
||||
* the string value in.
|
||||
*
|
||||
* We have to worry about overflow [Bugs 714106, 2561746].
|
||||
* At this point we know 1 <= length1 <= INT_MAX and 2 <= count <= INT_MAX.
|
||||
* We need to keep 2 <= length2 <= INT_MAX.
|
||||
*/
|
||||
|
||||
if (count > INT_MAX/length1) {
|
||||
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
|
||||
"result exceeds max size for a Tcl value (%d bytes)",
|
||||
INT_MAX));
|
||||
Tcl_SetErrorCode(interp, "TCL", "MEMORY", NULL);
|
||||
return TCL_ERROR;
|
||||
}
|
||||
length2 = length1 * count;
|
||||
|
||||
/*
|
||||
* Include space for the NUL.
|
||||
*/
|
||||
|
||||
string2 = attemptckalloc((unsigned) length2 + 1);
|
||||
if (string2 == NULL) {
|
||||
/*
|
||||
* Alloc failed. Note that in this case we try to do an error message
|
||||
* since this is a case that's most likely when the alloc is large and
|
||||
* that's easy to do with this API. Note that if we fail allocating a
|
||||
* short string, this will likely keel over too (and fatally).
|
||||
*/
|
||||
|
||||
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
|
||||
"string size overflow, out of memory allocating %u bytes",
|
||||
length2 + 1));
|
||||
Tcl_SetErrorCode(interp, "TCL", "MEMORY", NULL);
|
||||
return TCL_ERROR;
|
||||
}
|
||||
for (index = 0; index < count; index++) {
|
||||
memcpy(string2 + (length1 * index), string1, (size_t) length1);
|
||||
}
|
||||
string2[length2] = '\0';
|
||||
|
||||
/*
|
||||
* We have to directly assign this instead of using Tcl_SetStringObj (and
|
||||
* indirectly TclInitStringRep) because that makes another copy of the
|
||||
* data.
|
||||
*/
|
||||
|
||||
TclNewObj(resultPtr);
|
||||
resultPtr->bytes = string2;
|
||||
resultPtr->length = length2;
|
||||
Tcl_SetObjResult(interp, resultPtr);
|
||||
|
||||
done:
|
||||
return TCL_OK;
|
||||
}
|
||||
|
||||
@@ -2693,7 +2855,7 @@ StringCatCmd(
|
||||
int objc, /* Number of arguments. */
|
||||
Tcl_Obj *const objv[]) /* Argument objects. */
|
||||
{
|
||||
int code;
|
||||
int i;
|
||||
Tcl_Obj *objResultPtr;
|
||||
|
||||
if (objc < 2) {
|
||||
@@ -2710,16 +2872,16 @@ StringCatCmd(
|
||||
Tcl_SetObjResult(interp, objv[1]);
|
||||
return TCL_OK;
|
||||
}
|
||||
|
||||
code = TclStringCatObjv(interp, /* inPlace */ 1, objc-1, objv+1,
|
||||
&objResultPtr);
|
||||
|
||||
if (code == TCL_OK) {
|
||||
Tcl_SetObjResult(interp, objResultPtr);
|
||||
return TCL_OK;
|
||||
objResultPtr = objv[1];
|
||||
if (Tcl_IsShared(objResultPtr)) {
|
||||
objResultPtr = Tcl_DuplicateObj(objResultPtr);
|
||||
}
|
||||
for(i = 2;i < objc;i++) {
|
||||
Tcl_AppendObjToObj(objResultPtr, objv[i]);
|
||||
}
|
||||
Tcl_SetObjResult(interp, objResultPtr);
|
||||
|
||||
return code;
|
||||
return TCL_OK;
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -4157,7 +4319,7 @@ TclNRTryObjCmd(
|
||||
}
|
||||
|
||||
info[0] = objv[i]; /* type */
|
||||
TclNewLongObj(info[1], code); /* returnCode */
|
||||
TclNewIntObj(info[1], code); /* returnCode */
|
||||
if (info[2] == NULL) { /* errorCodePrefix */
|
||||
TclNewObj(info[2]);
|
||||
}
|
||||
|
||||
@@ -3206,6 +3206,17 @@ TclCompileFormatCmd(
|
||||
*/
|
||||
|
||||
TclEmitInstInt1(INST_STR_CONCAT1, i, envPtr);
|
||||
} else {
|
||||
/*
|
||||
* EVIL HACK! Force there to be a string representation in the case
|
||||
* where there's just a "%s" in the format; case covered by the test
|
||||
* format-20.1 (and it is horrible...)
|
||||
*/
|
||||
|
||||
TclEmitOpcode(INST_DUP, envPtr);
|
||||
PushStringLiteral(envPtr, "");
|
||||
TclEmitOpcode(INST_STR_EQ, envPtr);
|
||||
TclEmitOpcode(INST_POP, envPtr);
|
||||
}
|
||||
return TCL_OK;
|
||||
}
|
||||
|
||||
@@ -2761,7 +2761,7 @@ TclCompileSyntaxError(
|
||||
const char *bytes = TclGetStringFromObj(msg, &numBytes);
|
||||
|
||||
TclErrorStackResetIf(interp, bytes, numBytes);
|
||||
TclEmitPush(TclRegisterLiteral(envPtr, bytes, numBytes, 0), envPtr);
|
||||
TclEmitPush(TclRegisterNewLiteral(envPtr, bytes, numBytes), envPtr);
|
||||
CompileReturnInternal(envPtr, INST_SYNTAX, TCL_ERROR, 0,
|
||||
TclNoErrorStack(interp, Tcl_GetReturnOptions(interp, TCL_ERROR)));
|
||||
Tcl_ResetResult(interp);
|
||||
|
||||
@@ -1456,8 +1456,8 @@ TclSubstCompile(
|
||||
|
||||
switch (tokenPtr->type) {
|
||||
case TCL_TOKEN_TEXT:
|
||||
literal = TclRegisterLiteral(envPtr,
|
||||
tokenPtr->start, tokenPtr->size, 0);
|
||||
literal = TclRegisterNewLiteral(envPtr,
|
||||
tokenPtr->start, tokenPtr->size);
|
||||
TclEmitPush(literal, envPtr);
|
||||
TclAdvanceLines(&bline, tokenPtr->start,
|
||||
tokenPtr->start + tokenPtr->size);
|
||||
@@ -1466,7 +1466,7 @@ TclSubstCompile(
|
||||
case TCL_TOKEN_BS:
|
||||
length = TclParseBackslash(tokenPtr->start, tokenPtr->size,
|
||||
NULL, buf);
|
||||
literal = TclRegisterLiteral(envPtr, buf, length, 0);
|
||||
literal = TclRegisterNewLiteral(envPtr, buf, length);
|
||||
TclEmitPush(literal, envPtr);
|
||||
count++;
|
||||
continue;
|
||||
@@ -1902,10 +1902,10 @@ TclCompileSwitchCmd(
|
||||
}
|
||||
if (numWords % 2) {
|
||||
abort:
|
||||
ckfree(bodyToken);
|
||||
ckfree(bodyTokenArray);
|
||||
ckfree(bodyLines);
|
||||
ckfree(bodyContLines);
|
||||
ckfree((char *) bodyToken);
|
||||
ckfree((char *) bodyTokenArray);
|
||||
ckfree((char *) bodyLines);
|
||||
ckfree((char *) bodyContLines);
|
||||
return TCL_ERROR;
|
||||
}
|
||||
} else if (numWords % 2 || numWords == 0) {
|
||||
|
||||
@@ -2267,9 +2267,9 @@ CompileExprTree(
|
||||
p = TclGetStringFromObj(*funcObjv, &length);
|
||||
funcObjv++;
|
||||
Tcl_DStringAppend(&cmdName, p, length);
|
||||
TclEmitPush(TclRegisterLiteral(envPtr,
|
||||
TclEmitPush(TclRegisterNewCmdLiteral(envPtr,
|
||||
Tcl_DStringValue(&cmdName),
|
||||
Tcl_DStringLength(&cmdName), LITERAL_CMD_NAME), envPtr);
|
||||
Tcl_DStringLength(&cmdName)), envPtr);
|
||||
Tcl_DStringFree(&cmdName);
|
||||
|
||||
/*
|
||||
@@ -2376,8 +2376,8 @@ CompileExprTree(
|
||||
pc1 = CurrentOffset(envPtr);
|
||||
TclEmitInstInt1((nodePtr->lexeme == AND) ? INST_JUMP_FALSE1
|
||||
: INST_JUMP_TRUE1, 0, envPtr);
|
||||
TclEmitPush(TclRegisterLiteral(envPtr,
|
||||
(nodePtr->lexeme == AND) ? "1" : "0", 1, 0), envPtr);
|
||||
TclEmitPush(TclRegisterNewLiteral(envPtr,
|
||||
(nodePtr->lexeme == AND) ? "1" : "0", 1), envPtr);
|
||||
pc2 = CurrentOffset(envPtr);
|
||||
TclEmitInstInt1(INST_JUMP1, 0, envPtr);
|
||||
TclAdjustStackDepth(-1, envPtr);
|
||||
@@ -2386,8 +2386,8 @@ CompileExprTree(
|
||||
if (TclFixupForwardJumpToHere(envPtr, &jumpPtr->jump, 127)) {
|
||||
pc2 += 3;
|
||||
}
|
||||
TclEmitPush(TclRegisterLiteral(envPtr,
|
||||
(nodePtr->lexeme == AND) ? "0" : "1", 1, 0), envPtr);
|
||||
TclEmitPush(TclRegisterNewLiteral(envPtr,
|
||||
(nodePtr->lexeme == AND) ? "0" : "1", 1), envPtr);
|
||||
TclStoreInt1AtPtr(CurrentOffset(envPtr) - pc2,
|
||||
envPtr->codeStart + pc2 + 1);
|
||||
convert = 0;
|
||||
@@ -2421,7 +2421,7 @@ CompileExprTree(
|
||||
if (optimize) {
|
||||
int length;
|
||||
const char *bytes = TclGetStringFromObj(literal, &length);
|
||||
int index = TclRegisterLiteral(envPtr, bytes, length, 0);
|
||||
int index = TclRegisterNewLiteral(envPtr, bytes, length);
|
||||
Tcl_Obj *objPtr = TclFetchLiteral(envPtr, index);
|
||||
|
||||
if ((objPtr->typePtr == NULL) && (literal->typePtr != NULL)) {
|
||||
@@ -2479,8 +2479,8 @@ CompileExprTree(
|
||||
if (objPtr->bytes) {
|
||||
Tcl_Obj *tableValue;
|
||||
|
||||
index = TclRegisterLiteral(envPtr, objPtr->bytes,
|
||||
objPtr->length, 0);
|
||||
index = TclRegisterNewLiteral(envPtr, objPtr->bytes,
|
||||
objPtr->length);
|
||||
tableValue = TclFetchLiteral(envPtr, index);
|
||||
if ((tableValue->typePtr == NULL) &&
|
||||
(objPtr->typePtr != NULL)) {
|
||||
|
||||
+14
-25
@@ -765,8 +765,7 @@ TclSetByteCodeFromAny(
|
||||
Interp *iPtr = (Interp *) interp;
|
||||
CompileEnv compEnv; /* Compilation environment structure allocated
|
||||
* in frame. */
|
||||
size_t length;
|
||||
int result = TCL_OK;
|
||||
int length, result = TCL_OK;
|
||||
const char *stringPtr;
|
||||
Proc *procPtr = iPtr->compiledProcPtr;
|
||||
ContLineLoc *clLocPtr;
|
||||
@@ -781,8 +780,7 @@ TclSetByteCodeFromAny(
|
||||
}
|
||||
#endif
|
||||
|
||||
stringPtr = TclGetString(objPtr);
|
||||
length = objPtr->length;
|
||||
stringPtr = TclGetStringFromObj(objPtr, &length);
|
||||
|
||||
/*
|
||||
* TIP #280: Pick up the CmdFrame in which the BC compiler was invoked and
|
||||
@@ -1004,7 +1002,7 @@ void
|
||||
TclReleaseByteCode(
|
||||
register ByteCode *codePtr)
|
||||
{
|
||||
if (codePtr->refCount-- > 1) {
|
||||
if (--codePtr->refCount) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -1382,14 +1380,14 @@ ReleaseCmdWordData(
|
||||
Tcl_DecrRefCount(eclPtr->path);
|
||||
}
|
||||
for (i=0 ; i<eclPtr->nuloc ; i++) {
|
||||
ckfree(eclPtr->loc[i].line);
|
||||
ckfree((char *) eclPtr->loc[i].line);
|
||||
}
|
||||
|
||||
if (eclPtr->loc != NULL) {
|
||||
ckfree(eclPtr->loc);
|
||||
ckfree((char *) eclPtr->loc);
|
||||
}
|
||||
|
||||
ckfree(eclPtr);
|
||||
ckfree((char *) eclPtr);
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -1794,17 +1792,9 @@ CompileCmdLiteral(
|
||||
CompileEnv *envPtr)
|
||||
{
|
||||
int numBytes;
|
||||
const char *bytes;
|
||||
Command *cmdPtr;
|
||||
int cmdLitIdx, extraLiteralFlags = LITERAL_CMD_NAME;
|
||||
|
||||
cmdPtr = (Command *) Tcl_GetCommandFromObj(interp, cmdObj);
|
||||
if ((cmdPtr != NULL) && (cmdPtr->flags & CMD_VIA_RESOLVER)) {
|
||||
extraLiteralFlags |= LITERAL_UNSHARED;
|
||||
}
|
||||
|
||||
bytes = TclGetStringFromObj(cmdObj, &numBytes);
|
||||
cmdLitIdx = TclRegisterLiteral(envPtr, bytes, numBytes, extraLiteralFlags);
|
||||
const char *bytes = TclGetStringFromObj(cmdObj, &numBytes);
|
||||
int cmdLitIdx = TclRegisterNewCmdLiteral(envPtr, bytes, numBytes);
|
||||
Command *cmdPtr = (Command *) Tcl_GetCommandFromObj(interp, cmdObj);
|
||||
|
||||
if (cmdPtr) {
|
||||
TclSetCmdNameObj(interp, TclFetchLiteral(envPtr, cmdLitIdx), cmdPtr);
|
||||
@@ -1839,8 +1829,8 @@ TclCompileInvocation(
|
||||
continue;
|
||||
}
|
||||
|
||||
objIdx = TclRegisterLiteral(envPtr,
|
||||
tokenPtr[1].start, tokenPtr[1].size, 0);
|
||||
objIdx = TclRegisterNewLiteral(envPtr,
|
||||
tokenPtr[1].start, tokenPtr[1].size);
|
||||
if (envPtr->clNext) {
|
||||
TclContinuationsEnterDerived(TclFetchLiteral(envPtr, objIdx),
|
||||
tokenPtr[1].start - envPtr->source, envPtr->clNext);
|
||||
@@ -1889,8 +1879,8 @@ CompileExpanded(
|
||||
continue;
|
||||
}
|
||||
|
||||
objIdx = TclRegisterLiteral(envPtr,
|
||||
tokenPtr[1].start, tokenPtr[1].size, 0);
|
||||
objIdx = TclRegisterNewLiteral(envPtr,
|
||||
tokenPtr[1].start, tokenPtr[1].size);
|
||||
if (envPtr->clNext) {
|
||||
TclContinuationsEnterDerived(TclFetchLiteral(envPtr, objIdx),
|
||||
tokenPtr[1].start - envPtr->source, envPtr->clNext);
|
||||
@@ -2978,8 +2968,7 @@ TclFindCompiledLocal(
|
||||
varNamePtr = &cachePtr->varName0;
|
||||
for (i=0; i < cachePtr->numVars; varNamePtr++, i++) {
|
||||
if (*varNamePtr) {
|
||||
localName = TclGetString(*varNamePtr);
|
||||
len = (*varNamePtr)->length;
|
||||
localName = TclGetStringFromObj(*varNamePtr, &len);
|
||||
if ((len == nameBytes) && !strncmp(name, localName, len)) {
|
||||
return i;
|
||||
}
|
||||
|
||||
+27
-5
@@ -417,7 +417,7 @@ typedef struct ByteCode {
|
||||
* procs are specific to an interpreter so the
|
||||
* code emitted will depend on the
|
||||
* interpreter. */
|
||||
unsigned int compileEpoch; /* Value of iPtr->compileEpoch when this
|
||||
int compileEpoch; /* Value of iPtr->compileEpoch when this
|
||||
* ByteCode was compiled. Used to invalidate
|
||||
* code when, e.g., commands with compile
|
||||
* procs are redefined. */
|
||||
@@ -1095,7 +1095,7 @@ MODULE_SCOPE int TclCreateAuxData(ClientData clientData,
|
||||
MODULE_SCOPE int TclCreateExceptRange(ExceptionRangeType type,
|
||||
CompileEnv *envPtr);
|
||||
MODULE_SCOPE ExecEnv * TclCreateExecEnv(Tcl_Interp *interp, int size);
|
||||
MODULE_SCOPE Tcl_Obj * TclCreateLiteral(Interp *iPtr, const char *bytes,
|
||||
MODULE_SCOPE Tcl_Obj * TclCreateLiteral(Interp *iPtr, char *bytes,
|
||||
int length, unsigned int hash, int *newPtr,
|
||||
Namespace *nsPtr, int flags,
|
||||
LiteralEntry **globalPtrPtr);
|
||||
@@ -1210,7 +1210,29 @@ MODULE_SCOPE int TclPushProcCallFrame(ClientData clientData,
|
||||
|
||||
#define LITERAL_ON_HEAP 0x01
|
||||
#define LITERAL_CMD_NAME 0x02
|
||||
#define LITERAL_UNSHARED 0x04
|
||||
|
||||
/*
|
||||
* Form of TclRegisterLiteral with flags == 0. In that case, it is safe to
|
||||
* cast away constness, and it is cleanest to do that here, all in one place.
|
||||
*
|
||||
* int TclRegisterNewLiteral(CompileEnv *envPtr, const char *bytes,
|
||||
* int length);
|
||||
*/
|
||||
|
||||
#define TclRegisterNewLiteral(envPtr, bytes, length) \
|
||||
TclRegisterLiteral(envPtr, (char *)(bytes), length, /*flags*/ 0)
|
||||
|
||||
/*
|
||||
* Form of TclRegisterLiteral with flags == LITERAL_CMD_NAME. In that case, it
|
||||
* is safe to cast away constness, and it is cleanest to do that here, all in
|
||||
* one place.
|
||||
*
|
||||
* int TclRegisterNewNSLiteral(CompileEnv *envPtr, const char *bytes,
|
||||
* int length);
|
||||
*/
|
||||
|
||||
#define TclRegisterNewCmdLiteral(envPtr, bytes, length) \
|
||||
TclRegisterLiteral(envPtr, (char *)(bytes), length, LITERAL_CMD_NAME)
|
||||
|
||||
/*
|
||||
* Macro used to manually adjust the stack requirements; used in cases where
|
||||
@@ -1527,9 +1549,9 @@ MODULE_SCOPE int TclPushProcCallFrame(ClientData clientData,
|
||||
*/
|
||||
|
||||
#define PushLiteral(envPtr, string, length) \
|
||||
TclEmitPush(TclRegisterLiteral(envPtr, string, length, 0), (envPtr))
|
||||
TclEmitPush(TclRegisterNewLiteral((envPtr), (string), (length)), (envPtr))
|
||||
#define PushStringLiteral(envPtr, string) \
|
||||
PushLiteral(envPtr, string, (int) (sizeof(string "") - 1))
|
||||
PushLiteral((envPtr), (string), (int) (sizeof(string "") - 1))
|
||||
|
||||
/*
|
||||
* Macro to advance to the next token; it is more mnemonic than the address
|
||||
|
||||
+4
-4
@@ -232,7 +232,7 @@ QueryConfigObjCmd(
|
||||
|
||||
Tcl_SetObjResult(interp, Tcl_NewStringObj("package not known", -1));
|
||||
Tcl_SetErrorCode(interp, "TCL", "FATAL", "PKGCFG_BASE",
|
||||
TclGetString(pkgName), NULL);
|
||||
Tcl_GetString(pkgName), NULL);
|
||||
return TCL_ERROR;
|
||||
}
|
||||
|
||||
@@ -247,7 +247,7 @@ QueryConfigObjCmd(
|
||||
|| val == NULL) {
|
||||
Tcl_SetObjResult(interp, Tcl_NewStringObj("key not known", -1));
|
||||
Tcl_SetErrorCode(interp, "TCL", "LOOKUP", "CONFIG",
|
||||
TclGetString(objv[2]), NULL);
|
||||
Tcl_GetString(objv[2]), NULL);
|
||||
return TCL_ERROR;
|
||||
}
|
||||
|
||||
@@ -333,9 +333,9 @@ QueryConfigDelete(
|
||||
Tcl_DictObjRemove(NULL, pDB, pkgName);
|
||||
Tcl_DecrRefCount(pkgName);
|
||||
if (cdPtr->encoding) {
|
||||
ckfree(cdPtr->encoding);
|
||||
ckfree((char *)cdPtr->encoding);
|
||||
}
|
||||
ckfree(cdPtr);
|
||||
ckfree((char *)cdPtr);
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
+20
-45
@@ -142,7 +142,7 @@ typedef struct Dict {
|
||||
* the entries in the order that they are
|
||||
* created. */
|
||||
int epoch; /* Epoch counter */
|
||||
size_t refCount; /* Reference counter (see above) */
|
||||
int refcount; /* Reference counter (see above) */
|
||||
Tcl_Obj *chain; /* Linked list used for invalidating the
|
||||
* string representations of updated nested
|
||||
* dictionaries. */
|
||||
@@ -392,7 +392,7 @@ DupDictInternalRep(
|
||||
|
||||
newDict->epoch = 0;
|
||||
newDict->chain = NULL;
|
||||
newDict->refCount = 1;
|
||||
newDict->refcount = 1;
|
||||
|
||||
/*
|
||||
* Store in the object.
|
||||
@@ -427,7 +427,8 @@ FreeDictInternalRep(
|
||||
{
|
||||
Dict *dict = DICT(dictPtr);
|
||||
|
||||
if (dict->refCount-- <= 1) {
|
||||
dict->refcount--;
|
||||
if (dict->refcount <= 0) {
|
||||
DeleteDict(dict);
|
||||
}
|
||||
dictPtr->typePtr = NULL;
|
||||
@@ -712,7 +713,7 @@ SetDictFromAny(
|
||||
TclFreeIntRep(objPtr);
|
||||
dict->epoch = 0;
|
||||
dict->chain = NULL;
|
||||
dict->refCount = 1;
|
||||
dict->refcount = 1;
|
||||
DICT(objPtr) = dict;
|
||||
objPtr->internalRep.twoPtrValue.ptr2 = NULL;
|
||||
objPtr->typePtr = &tclDictType;
|
||||
@@ -1116,7 +1117,7 @@ Tcl_DictObjFirst(
|
||||
searchPtr->dictionaryPtr = (Tcl_Dict) dict;
|
||||
searchPtr->epoch = dict->epoch;
|
||||
searchPtr->next = cPtr->nextPtr;
|
||||
dict->refCount++;
|
||||
dict->refcount++;
|
||||
if (keyPtrPtr != NULL) {
|
||||
*keyPtrPtr = Tcl_GetHashKey(&dict->table, &cPtr->entry);
|
||||
}
|
||||
@@ -1230,7 +1231,8 @@ Tcl_DictObjDone(
|
||||
if (searchPtr->epoch != -1) {
|
||||
searchPtr->epoch = -1;
|
||||
dict = (Dict *) searchPtr->dictionaryPtr;
|
||||
if (dict->refCount-- <= 1) {
|
||||
dict->refcount--;
|
||||
if (dict->refcount <= 0) {
|
||||
DeleteDict(dict);
|
||||
}
|
||||
}
|
||||
@@ -1382,7 +1384,7 @@ Tcl_NewDictObj(void)
|
||||
InitChainTable(dict);
|
||||
dict->epoch = 0;
|
||||
dict->chain = NULL;
|
||||
dict->refCount = 1;
|
||||
dict->refcount = 1;
|
||||
DICT(dictPtr) = dict;
|
||||
dictPtr->internalRep.twoPtrValue.ptr2 = NULL;
|
||||
dictPtr->typePtr = &tclDictType;
|
||||
@@ -1432,7 +1434,7 @@ Tcl_DbNewDictObj(
|
||||
InitChainTable(dict);
|
||||
dict->epoch = 0;
|
||||
dict->chain = NULL;
|
||||
dict->refCount = 1;
|
||||
dict->refcount = 1;
|
||||
DICT(dictPtr) = dict;
|
||||
dictPtr->internalRep.twoPtrValue.ptr2 = NULL;
|
||||
dictPtr->typePtr = &tclDictType;
|
||||
@@ -2280,7 +2282,7 @@ DictAppendCmd(
|
||||
Tcl_Obj *const *objv)
|
||||
{
|
||||
Tcl_Obj *dictPtr, *valuePtr, *resultPtr;
|
||||
int allocatedDict = 0;
|
||||
int i, allocatedDict = 0;
|
||||
|
||||
if (objc < 3) {
|
||||
Tcl_WrongNumArgs(interp, 1, objv, "dictVarName key ?value ...?");
|
||||
@@ -2303,44 +2305,17 @@ DictAppendCmd(
|
||||
return TCL_ERROR;
|
||||
}
|
||||
|
||||
if ((objc > 3) || (valuePtr == NULL)) {
|
||||
/* Only go through append activites when something will change. */
|
||||
Tcl_Obj *appendObjPtr = NULL;
|
||||
|
||||
if (objc > 3) {
|
||||
/* Something to append */
|
||||
|
||||
if (objc == 4) {
|
||||
appendObjPtr = objv[3];
|
||||
} else if (TCL_OK != TclStringCatObjv(interp, /* inPlace */ 1,
|
||||
objc-3, objv+3, &appendObjPtr)) {
|
||||
return TCL_ERROR;
|
||||
}
|
||||
}
|
||||
|
||||
if (appendObjPtr == NULL) {
|
||||
/* => (objc == 3) => (valuePtr == NULL) */
|
||||
TclNewObj(valuePtr);
|
||||
} else if (valuePtr == NULL) {
|
||||
valuePtr = appendObjPtr;
|
||||
appendObjPtr = NULL;
|
||||
}
|
||||
|
||||
if (appendObjPtr) {
|
||||
if (Tcl_IsShared(valuePtr)) {
|
||||
valuePtr = Tcl_DuplicateObj(valuePtr);
|
||||
}
|
||||
|
||||
Tcl_AppendObjToObj(valuePtr, appendObjPtr);
|
||||
}
|
||||
|
||||
Tcl_DictObjPut(NULL, dictPtr, objv[2], valuePtr);
|
||||
if (valuePtr == NULL) {
|
||||
TclNewObj(valuePtr);
|
||||
} else if (Tcl_IsShared(valuePtr)) {
|
||||
valuePtr = Tcl_DuplicateObj(valuePtr);
|
||||
}
|
||||
|
||||
/*
|
||||
* Even if nothing changed, we still overwrite so that variable
|
||||
* trace expectations are met.
|
||||
*/
|
||||
for (i=3 ; i<objc ; i++) {
|
||||
Tcl_AppendObjToObj(valuePtr, objv[i]);
|
||||
}
|
||||
|
||||
Tcl_DictObjPut(NULL, dictPtr, objv[2], valuePtr);
|
||||
|
||||
resultPtr = Tcl_ObjSetVar2(interp, objv[1], NULL, dictPtr,
|
||||
TCL_LEAVE_ERR_MSG);
|
||||
|
||||
+18
-15
@@ -46,7 +46,7 @@ typedef struct Encoding {
|
||||
* nullSize is 2, this is a function that
|
||||
* returns the number of bytes in a 0x0000
|
||||
* terminated string. */
|
||||
size_t refCount; /* Number of uses of this structure. */
|
||||
int refCount; /* Number of uses of this structure. */
|
||||
Tcl_HashEntry *hPtr; /* Hash table entry that owns this encoding. */
|
||||
} Encoding;
|
||||
|
||||
@@ -305,7 +305,7 @@ Tcl_GetEncodingFromObj(
|
||||
Tcl_Obj *objPtr,
|
||||
Tcl_Encoding *encodingPtr)
|
||||
{
|
||||
const char *name = TclGetString(objPtr);
|
||||
const char *name = Tcl_GetString(objPtr);
|
||||
|
||||
if (objPtr->typePtr != &encodingType) {
|
||||
Tcl_Encoding encoding = Tcl_GetEncoding(interp, name);
|
||||
@@ -705,7 +705,7 @@ Tcl_GetDefaultEncodingDir(void)
|
||||
}
|
||||
Tcl_ListObjIndex(NULL, searchPath, 0, &first);
|
||||
|
||||
return TclGetString(first);
|
||||
return Tcl_GetString(first);
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -844,7 +844,11 @@ FreeEncoding(
|
||||
if (encodingPtr == NULL) {
|
||||
return;
|
||||
}
|
||||
if (encodingPtr->refCount-- <= 1) {
|
||||
if (encodingPtr->refCount<=0) {
|
||||
Tcl_Panic("FreeEncoding: refcount problem !!!");
|
||||
}
|
||||
encodingPtr->refCount--;
|
||||
if (encodingPtr->refCount == 0) {
|
||||
if (encodingPtr->freeProc != NULL) {
|
||||
encodingPtr->freeProc(encodingPtr->clientData);
|
||||
}
|
||||
@@ -973,7 +977,7 @@ Tcl_GetEncodingNames(
|
||||
* Side effects:
|
||||
* The reference count of the new system encoding is incremented. The
|
||||
* reference count of the old system encoding is decremented and it may
|
||||
* be freed. All VFS cached information is invalidated.
|
||||
* be freed.
|
||||
*
|
||||
*------------------------------------------------------------------------
|
||||
*/
|
||||
@@ -1004,7 +1008,6 @@ Tcl_SetSystemEncoding(
|
||||
FreeEncoding(systemEncoding);
|
||||
systemEncoding = encoding;
|
||||
Tcl_MutexUnlock(&encodingMutex);
|
||||
Tcl_FSMountsChanged(NULL);
|
||||
|
||||
return TCL_OK;
|
||||
}
|
||||
@@ -1515,10 +1518,10 @@ OpenEncodingFileChannel(
|
||||
}
|
||||
}
|
||||
if (!verified) {
|
||||
const char *dirString = TclGetString(directory);
|
||||
const char *dirString = Tcl_GetString(directory);
|
||||
|
||||
for (i=0; i<numDirs && !verified; i++) {
|
||||
if (strcmp(dirString, TclGetString(dir[i])) == 0) {
|
||||
if (strcmp(dirString, Tcl_GetString(dir[i])) == 0) {
|
||||
verified = 1;
|
||||
}
|
||||
}
|
||||
@@ -1759,7 +1762,7 @@ LoadTableEncoding(
|
||||
const char *p;
|
||||
|
||||
Tcl_ReadChars(chan, objPtr, 3 + 16 * (16 * 4 + 1), 0);
|
||||
p = TclGetString(objPtr);
|
||||
p = Tcl_GetString(objPtr);
|
||||
hi = (staticHex[UCHAR(p[0])] << 4) + staticHex[UCHAR(p[1])];
|
||||
dataPtr->toUnicode[hi] = pageMemPtr;
|
||||
p += 2;
|
||||
@@ -3596,11 +3599,11 @@ unilen(
|
||||
static void
|
||||
InitializeEncodingSearchPath(
|
||||
char **valuePtr,
|
||||
size_t *lengthPtr,
|
||||
int *lengthPtr,
|
||||
Tcl_Encoding *encodingPtr)
|
||||
{
|
||||
const char *bytes;
|
||||
int i, numDirs;
|
||||
int i, numDirs, numBytes;
|
||||
Tcl_Obj *libPathObj, *encodingObj, *searchPathObj;
|
||||
|
||||
TclNewLiteralStringObj(encodingObj, "encoding");
|
||||
@@ -3630,11 +3633,11 @@ InitializeEncodingSearchPath(
|
||||
if (*encodingPtr) {
|
||||
((Encoding *)(*encodingPtr))->refCount++;
|
||||
}
|
||||
bytes = TclGetString(searchPathObj);
|
||||
bytes = TclGetStringFromObj(searchPathObj, &numBytes);
|
||||
|
||||
*lengthPtr = searchPathObj->length;
|
||||
*valuePtr = ckalloc(*lengthPtr + 1);
|
||||
memcpy(*valuePtr, bytes, *lengthPtr + 1);
|
||||
*lengthPtr = numBytes;
|
||||
*valuePtr = ckalloc(numBytes + 1);
|
||||
memcpy(*valuePtr, bytes, (size_t) numBytes + 1);
|
||||
Tcl_DecrRefCount(searchPathObj);
|
||||
}
|
||||
|
||||
|
||||
+9
-12
@@ -1605,7 +1605,7 @@ TclMakeEnsemble(
|
||||
Tcl_DStringFree(&buf);
|
||||
Tcl_DStringFree(&hiddenBuf);
|
||||
if (nameParts != NULL) {
|
||||
ckfree(nameParts);
|
||||
ckfree((char *) nameParts);
|
||||
}
|
||||
return ensemble;
|
||||
}
|
||||
@@ -3135,7 +3135,7 @@ TclCompileEnsemble(
|
||||
* any extra elements that might have been appended by failing
|
||||
* pathways above.
|
||||
*/
|
||||
(void) Tcl_ListObjReplace(NULL, replaced, depth-1, LIST_MAX, 0, NULL);
|
||||
(void) Tcl_ListObjReplace(NULL, replaced, depth-1, INT_MAX, 0, NULL);
|
||||
|
||||
/*
|
||||
* TODO: Reconsider whether we ought to call CompileToInvokedCommand()
|
||||
@@ -3306,7 +3306,7 @@ CompileToInvokedCommand(
|
||||
Tcl_Token *tokPtr;
|
||||
Tcl_Obj *objPtr, **words;
|
||||
char *bytes;
|
||||
int i, numWords, cmdLit, extraLiteralFlags = LITERAL_CMD_NAME;
|
||||
int length, i, numWords, cmdLit;
|
||||
DefineLineInformation;
|
||||
|
||||
/*
|
||||
@@ -3319,15 +3319,15 @@ CompileToInvokedCommand(
|
||||
for (i = 0, tokPtr = parsePtr->tokenPtr; i < parsePtr->numWords;
|
||||
i++, tokPtr = TokenAfter(tokPtr)) {
|
||||
if (i > 0 && i < numWords+1) {
|
||||
bytes = TclGetString(words[i-1]);
|
||||
PushLiteral(envPtr, bytes, words[i-1]->length);
|
||||
bytes = TclGetStringFromObj(words[i-1], &length);
|
||||
PushLiteral(envPtr, bytes, length);
|
||||
continue;
|
||||
}
|
||||
|
||||
SetLineInformation(i);
|
||||
if (tokPtr->type == TCL_TOKEN_SIMPLE_WORD) {
|
||||
int literal = TclRegisterLiteral(envPtr,
|
||||
tokPtr[1].start, tokPtr[1].size, 0);
|
||||
int literal = TclRegisterNewLiteral(envPtr,
|
||||
tokPtr[1].start, tokPtr[1].size);
|
||||
|
||||
if (envPtr->clNext) {
|
||||
TclContinuationsEnterDerived(
|
||||
@@ -3348,11 +3348,8 @@ CompileToInvokedCommand(
|
||||
|
||||
objPtr = Tcl_NewObj();
|
||||
Tcl_GetCommandFullName(interp, (Tcl_Command) cmdPtr, objPtr);
|
||||
bytes = TclGetString(objPtr);
|
||||
if ((cmdPtr != NULL) && (cmdPtr->flags & CMD_VIA_RESOLVER)) {
|
||||
extraLiteralFlags |= LITERAL_UNSHARED;
|
||||
}
|
||||
cmdLit = TclRegisterLiteral(envPtr, bytes, objPtr->length, extraLiteralFlags);
|
||||
bytes = TclGetStringFromObj(objPtr, &length);
|
||||
cmdLit = TclRegisterNewCmdLiteral(envPtr, bytes, length);
|
||||
TclSetCmdNameObj(interp, TclFetchLiteral(envPtr, cmdLit), cmdPtr);
|
||||
TclEmitPush(cmdLit, envPtr);
|
||||
TclDecrRefCount(objPtr);
|
||||
|
||||
+39
-16
@@ -1497,26 +1497,49 @@ Tcl_UpdateObjCmd(
|
||||
{
|
||||
int optionIndex;
|
||||
int flags = 0; /* Initialized to avoid compiler warning. */
|
||||
static const char *const updateOptions[] = {"idletasks", NULL};
|
||||
enum updateOptions {OPT_IDLETASKS};
|
||||
int index;
|
||||
static const char *const updateOptions[] = {"idletasks", "window", "file", "timer", "onlyidle", "all", "wait", "nowait", NULL};
|
||||
enum updateOptions {OPT_IDLETASKS, OPT_WINDOW, OPT_FILE, OPT_TIMER, OPT_ONLYIDLE, OPT_ALL, OPT_WAIT, OPT_NOWAIT};
|
||||
|
||||
if (objc == 1) {
|
||||
flags = TCL_ALL_EVENTS|TCL_DONT_WAIT;
|
||||
} else if (objc == 2) {
|
||||
if (Tcl_GetIndexFromObj(interp, objv[1], updateOptions,
|
||||
"option", 0, &optionIndex) != TCL_OK) {
|
||||
return TCL_ERROR;
|
||||
}
|
||||
switch ((enum updateOptions) optionIndex) {
|
||||
case OPT_IDLETASKS:
|
||||
flags = TCL_WINDOW_EVENTS|TCL_IDLE_EVENTS|TCL_DONT_WAIT;
|
||||
break;
|
||||
default:
|
||||
Tcl_Panic("Tcl_UpdateObjCmd: bad option index to UpdateOptions");
|
||||
}
|
||||
} else {
|
||||
Tcl_WrongNumArgs(interp, 1, objv, "?idletasks?");
|
||||
return TCL_ERROR;
|
||||
flags = 0;
|
||||
for (index = 1; index < objc; index++) {
|
||||
if (Tcl_GetIndexFromObj(interp, objv[index], updateOptions,
|
||||
"option", 0, &optionIndex) != TCL_OK) {
|
||||
return TCL_ERROR;
|
||||
}
|
||||
|
||||
switch ((enum updateOptions) optionIndex) {
|
||||
case OPT_IDLETASKS:
|
||||
flags = TCL_WINDOW_EVENTS|TCL_IDLE_EVENTS|TCL_DONT_WAIT;
|
||||
break;
|
||||
case OPT_WINDOW:
|
||||
flags |= TCL_WINDOW_EVENTS; // Process window system events.
|
||||
break;
|
||||
case OPT_FILE:
|
||||
flags |= TCL_FILE_EVENTS; // Process file events.
|
||||
break;
|
||||
case OPT_TIMER:
|
||||
flags |= TCL_TIMER_EVENTS; // Process timer events.
|
||||
break;
|
||||
case OPT_ONLYIDLE:
|
||||
flags |= TCL_IDLE_EVENTS; // Process idle callbacks.
|
||||
break;
|
||||
case OPT_ALL:
|
||||
flags |= TCL_ALL_EVENTS; // Process all kinds of events
|
||||
break;
|
||||
case OPT_WAIT:
|
||||
flags &= ~TCL_DONT_WAIT; // Sleep until an event occurs
|
||||
break;
|
||||
case OPT_NOWAIT:
|
||||
flags |= TCL_DONT_WAIT; // Do not sleep: process only events that are ready at the time of the call.
|
||||
break;
|
||||
default:
|
||||
Tcl_Panic("Tcl_UpdateObjCmd: bad option index to UpdateOptions");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
while (Tcl_DoOneEvent(flags) != 0) {
|
||||
|
||||
+294
-82
@@ -19,6 +19,7 @@
|
||||
#include "tclCompile.h"
|
||||
#include "tclOOInt.h"
|
||||
#include "tommath.h"
|
||||
#include "tclStringRep.h"
|
||||
#include <math.h>
|
||||
#include <assert.h>
|
||||
|
||||
@@ -325,7 +326,7 @@ VarHashCreateVar(
|
||||
NEXT_INST_F(((condition)? TclGetInt4AtPtr(pc+1) : 5), (cleanup), 0); \
|
||||
default: \
|
||||
if ((condition) < 0) { \
|
||||
TclNewLongObj(objResultPtr, -1); \
|
||||
TclNewIntObj(objResultPtr, -1); \
|
||||
} else { \
|
||||
objResultPtr = TCONST((condition) > 0); \
|
||||
} \
|
||||
@@ -346,7 +347,7 @@ VarHashCreateVar(
|
||||
NEXT_INST_V(((condition)? TclGetInt4AtPtr(pc+1) : 5), (cleanup), 0); \
|
||||
default: \
|
||||
if ((condition) < 0) { \
|
||||
TclNewLongObj(objResultPtr, -1); \
|
||||
TclNewIntObj(objResultPtr, -1); \
|
||||
} else { \
|
||||
objResultPtr = TCONST((condition) > 0); \
|
||||
} \
|
||||
@@ -357,7 +358,7 @@ VarHashCreateVar(
|
||||
#define JUMP_PEEPHOLE_F(condition, pcAdjustment, cleanup) \
|
||||
do{ \
|
||||
if ((condition) < 0) { \
|
||||
TclNewLongObj(objResultPtr, -1); \
|
||||
TclNewIntObj(objResultPtr, -1); \
|
||||
} else { \
|
||||
objResultPtr = TCONST((condition) > 0); \
|
||||
} \
|
||||
@@ -366,7 +367,7 @@ VarHashCreateVar(
|
||||
#define JUMP_PEEPHOLE_V(condition, pcAdjustment, cleanup) \
|
||||
do{ \
|
||||
if ((condition) < 0) { \
|
||||
TclNewLongObj(objResultPtr, -1); \
|
||||
TclNewIntObj(objResultPtr, -1); \
|
||||
} else { \
|
||||
objResultPtr = TCONST((condition) > 0); \
|
||||
} \
|
||||
@@ -1274,7 +1275,7 @@ TclStackFree(
|
||||
Tcl_Obj **markerPtr, *marker;
|
||||
|
||||
if (iPtr == NULL || iPtr->execEnvPtr == NULL) {
|
||||
ckfree(freePtr);
|
||||
ckfree((char *) freePtr);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -1541,10 +1542,11 @@ CompileExprObj(
|
||||
* TIP #280: No invoker (yet) - Expression compilation.
|
||||
*/
|
||||
|
||||
const char *string = TclGetString(objPtr);
|
||||
int length;
|
||||
const char *string = TclGetStringFromObj(objPtr, &length);
|
||||
|
||||
TclInitCompileEnv(interp, &compEnv, string, objPtr->length, NULL, 0);
|
||||
TclCompileExpr(interp, string, objPtr->length, &compEnv, 0);
|
||||
TclInitCompileEnv(interp, &compEnv, string, length, NULL, 0);
|
||||
TclCompileExpr(interp, string, length, &compEnv, 0);
|
||||
|
||||
/*
|
||||
* Successful compilation. If the expression yielded no instructions,
|
||||
@@ -1552,7 +1554,7 @@ CompileExprObj(
|
||||
*/
|
||||
|
||||
if (compEnv.codeNext == compEnv.codeStart) {
|
||||
TclEmitPush(TclRegisterLiteral(&compEnv, "0", 1, 0),
|
||||
TclEmitPush(TclRegisterNewLiteral(&compEnv, "0", 1),
|
||||
&compEnv);
|
||||
}
|
||||
|
||||
@@ -2536,7 +2538,7 @@ TEBCresume(
|
||||
/* FIXME: What is the right thing to trace? */
|
||||
fprintf(stdout, "%d: (%u) yielding to [%.30s]\n",
|
||||
iPtr->numLevels, (unsigned)(pc - codePtr->codeStart),
|
||||
TclGetString(valuePtr));
|
||||
Tcl_GetString(valuePtr));
|
||||
}
|
||||
fflush(stdout);
|
||||
}
|
||||
@@ -2683,18 +2685,154 @@ TEBCresume(
|
||||
NEXT_INST_F(5, 0, 0);
|
||||
}
|
||||
|
||||
case INST_STR_CONCAT1:
|
||||
case INST_STR_CONCAT1: {
|
||||
int appendLen = 0;
|
||||
char *bytes, *p;
|
||||
Tcl_Obj **currPtr;
|
||||
int onlyb = 1;
|
||||
|
||||
opnd = TclGetUInt1AtPtr(pc+1);
|
||||
|
||||
if (TCL_OK != TclStringCatObjv(interp, /* inPlace */ 1,
|
||||
opnd, &OBJ_AT_DEPTH(opnd-1), &objResultPtr)) {
|
||||
TRACE_ERROR(interp);
|
||||
goto gotError;
|
||||
/*
|
||||
* Detect only-bytearray-or-null case.
|
||||
*/
|
||||
|
||||
for (currPtr=&OBJ_AT_DEPTH(opnd-1); currPtr<=&OBJ_AT_TOS; currPtr++) {
|
||||
if (((*currPtr)->typePtr != &tclByteArrayType)
|
||||
&& ((*currPtr)->bytes != tclEmptyStringRep)) {
|
||||
onlyb = 0;
|
||||
break;
|
||||
} else if (((*currPtr)->typePtr == &tclByteArrayType) &&
|
||||
((*currPtr)->bytes != NULL)) {
|
||||
onlyb = 0;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Compute the length to be appended.
|
||||
*/
|
||||
|
||||
if (onlyb) {
|
||||
for (currPtr = &OBJ_AT_DEPTH(opnd-2);
|
||||
appendLen >= 0 && currPtr <= &OBJ_AT_TOS; currPtr++) {
|
||||
if ((*currPtr)->bytes != tclEmptyStringRep) {
|
||||
Tcl_GetByteArrayFromObj(*currPtr, &length);
|
||||
appendLen += length;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
for (currPtr = &OBJ_AT_DEPTH(opnd-2);
|
||||
appendLen >= 0 && currPtr <= &OBJ_AT_TOS; currPtr++) {
|
||||
bytes = TclGetStringFromObj(*currPtr, &length);
|
||||
if (bytes != NULL) {
|
||||
appendLen += length;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (appendLen < 0) {
|
||||
/* TODO: convert panic to error ? */
|
||||
Tcl_Panic("max size for a Tcl value (%d bytes) exceeded", INT_MAX);
|
||||
}
|
||||
|
||||
/*
|
||||
* If nothing is to be appended, just return the first object by
|
||||
* dropping all the others from the stack; this saves both the
|
||||
* computation and copy of the string rep of the first object,
|
||||
* enabling the fast '$x[set x {}]' idiom for 'K $x [set x {}]'.
|
||||
*/
|
||||
|
||||
if (appendLen == 0) {
|
||||
TRACE_WITH_OBJ(("%u => ", opnd), objResultPtr);
|
||||
NEXT_INST_V(2, (opnd-1), 0);
|
||||
}
|
||||
|
||||
/*
|
||||
* If the first object is shared, we need a new obj for the result;
|
||||
* otherwise, we can reuse the first object. In any case, make sure it
|
||||
* has enough room to accomodate all the concatenated bytes. Note that
|
||||
* if it is unshared its bytes are copied by ckrealloc, so that we set
|
||||
* the loop parameters to avoid copying them again: p points to the
|
||||
* end of the already copied bytes, currPtr to the second object.
|
||||
*/
|
||||
|
||||
objResultPtr = OBJ_AT_DEPTH(opnd-1);
|
||||
if (!onlyb) {
|
||||
bytes = TclGetStringFromObj(objResultPtr, &length);
|
||||
if (length + appendLen < 0) {
|
||||
/* TODO: convert panic to error ? */
|
||||
Tcl_Panic("max size for a Tcl value (%d bytes) exceeded",
|
||||
INT_MAX);
|
||||
}
|
||||
#ifndef TCL_COMPILE_DEBUG
|
||||
if (bytes != tclEmptyStringRep && !Tcl_IsShared(objResultPtr)) {
|
||||
TclFreeIntRep(objResultPtr);
|
||||
objResultPtr->bytes = ckrealloc(bytes, length+appendLen+1);
|
||||
objResultPtr->length = length + appendLen;
|
||||
p = TclGetString(objResultPtr) + length;
|
||||
currPtr = &OBJ_AT_DEPTH(opnd - 2);
|
||||
} else
|
||||
#endif
|
||||
{
|
||||
p = ckalloc(length + appendLen + 1);
|
||||
TclNewObj(objResultPtr);
|
||||
objResultPtr->bytes = p;
|
||||
objResultPtr->length = length + appendLen;
|
||||
currPtr = &OBJ_AT_DEPTH(opnd - 1);
|
||||
}
|
||||
|
||||
/*
|
||||
* Append the remaining characters.
|
||||
*/
|
||||
|
||||
for (; currPtr <= &OBJ_AT_TOS; currPtr++) {
|
||||
bytes = TclGetStringFromObj(*currPtr, &length);
|
||||
if (bytes != NULL) {
|
||||
memcpy(p, bytes, (size_t) length);
|
||||
p += length;
|
||||
}
|
||||
}
|
||||
*p = '\0';
|
||||
} else {
|
||||
bytes = (char *) Tcl_GetByteArrayFromObj(objResultPtr, &length);
|
||||
if (length + appendLen < 0) {
|
||||
/* TODO: convert panic to error ? */
|
||||
Tcl_Panic("max size for a Tcl value (%d bytes) exceeded",
|
||||
INT_MAX);
|
||||
}
|
||||
#ifndef TCL_COMPILE_DEBUG
|
||||
if (!Tcl_IsShared(objResultPtr)) {
|
||||
bytes = (char *) Tcl_SetByteArrayLength(objResultPtr,
|
||||
length + appendLen);
|
||||
p = bytes + length;
|
||||
currPtr = &OBJ_AT_DEPTH(opnd - 2);
|
||||
} else
|
||||
#endif
|
||||
{
|
||||
TclNewObj(objResultPtr);
|
||||
bytes = (char *) Tcl_SetByteArrayLength(objResultPtr,
|
||||
length + appendLen);
|
||||
p = bytes;
|
||||
currPtr = &OBJ_AT_DEPTH(opnd - 1);
|
||||
}
|
||||
|
||||
/*
|
||||
* Append the remaining characters.
|
||||
*/
|
||||
|
||||
for (; currPtr <= &OBJ_AT_TOS; currPtr++) {
|
||||
if ((*currPtr)->bytes != tclEmptyStringRep) {
|
||||
bytes = (char *) Tcl_GetByteArrayFromObj(*currPtr,&length);
|
||||
memcpy(p, bytes, (size_t) length);
|
||||
p += length;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
TRACE_WITH_OBJ(("%u => ", opnd), objResultPtr);
|
||||
NEXT_INST_V(2, opnd, 1);
|
||||
}
|
||||
|
||||
case INST_CONCAT_STK:
|
||||
/*
|
||||
@@ -3035,7 +3173,7 @@ TEBCresume(
|
||||
Tcl_Obj *copyPtr = Tcl_NewListObj(objc - opnd + 1, NULL);
|
||||
|
||||
Tcl_ListObjAppendElement(NULL, copyPtr, objPtr);
|
||||
Tcl_ListObjReplace(NULL, copyPtr, LIST_MAX, 0,
|
||||
Tcl_ListObjReplace(NULL, copyPtr, LIST_MAX, 0,
|
||||
objc - opnd, objv + opnd);
|
||||
Tcl_DecrRefCount(objPtr);
|
||||
objPtr = copyPtr;
|
||||
@@ -4034,13 +4172,12 @@ TEBCresume(
|
||||
}
|
||||
TRACE(("%s %u \"%.30s\" => ",
|
||||
(flags ? "normal" : "noerr"), opnd, O2S(part2Ptr)));
|
||||
if (TclIsVarArray(arrayPtr) && !UnsetTraced(arrayPtr)
|
||||
&& !TclIsVarArraySearched(arrayPtr)) {
|
||||
if (TclIsVarArray(arrayPtr) && !UnsetTraced(arrayPtr)) {
|
||||
varPtr = VarHashFindVar(arrayPtr->value.tablePtr, part2Ptr);
|
||||
if (varPtr && TclIsVarDirectUnsettable(varPtr)) {
|
||||
/*
|
||||
* No nasty traces or searchesw and element exists, so we can
|
||||
* proceed to unset it. Might still not exist though...
|
||||
* No nasty traces and element exists, so we can proceed to
|
||||
* unset it. Might still not exist though...
|
||||
*/
|
||||
|
||||
if (!TclIsVarUndefined(varPtr)) {
|
||||
@@ -4529,7 +4666,7 @@ TEBCresume(
|
||||
NEXT_INST_F(1, 0, 1);
|
||||
}
|
||||
case INST_INFO_LEVEL_NUM:
|
||||
TclNewLongObj(objResultPtr, iPtr->varFramePtr->level);
|
||||
TclNewIntObj(objResultPtr, iPtr->varFramePtr->level);
|
||||
TRACE_WITH_OBJ(("=> "), objResultPtr);
|
||||
NEXT_INST_F(1, 0, 1);
|
||||
case INST_INFO_LEVEL_ARGS: {
|
||||
@@ -4898,7 +5035,7 @@ TEBCresume(
|
||||
TRACE_ERROR(interp);
|
||||
goto gotError;
|
||||
}
|
||||
TclNewLongObj(objResultPtr, length);
|
||||
TclNewIntObj(objResultPtr, length);
|
||||
TRACE_APPEND(("%d\n", length));
|
||||
NEXT_INST_F(1, 1, 1);
|
||||
|
||||
@@ -5369,7 +5506,7 @@ TEBCresume(
|
||||
case INST_STR_LEN:
|
||||
valuePtr = OBJ_AT_TOS;
|
||||
length = Tcl_GetCharLength(valuePtr);
|
||||
TclNewLongObj(objResultPtr, length);
|
||||
TclNewIntObj(objResultPtr, length);
|
||||
TRACE(("\"%.20s\" => %d\n", O2S(valuePtr), length));
|
||||
NEXT_INST_F(1, 1, 1);
|
||||
|
||||
@@ -5574,6 +5711,17 @@ TEBCresume(
|
||||
|
||||
length3 = Tcl_GetCharLength(value3Ptr);
|
||||
|
||||
/*
|
||||
* Remove substring. In-place.
|
||||
*/
|
||||
|
||||
if (length3 == 0 && !Tcl_IsShared(valuePtr) && toIdx == length) {
|
||||
TclDecrRefCount(value3Ptr);
|
||||
Tcl_SetObjLength(valuePtr, fromIdx);
|
||||
TRACE_APPEND(("\"%.30s\"\n", O2S(valuePtr)));
|
||||
NEXT_INST_F(1, 0, 0);
|
||||
}
|
||||
|
||||
/*
|
||||
* See if we can splice in place. This happens when the number of
|
||||
* characters being replaced is the same as the number of characters
|
||||
@@ -5583,29 +5731,51 @@ TEBCresume(
|
||||
if (length3 - 1 == toIdx - fromIdx) {
|
||||
unsigned char *bytes1, *bytes2;
|
||||
|
||||
/*
|
||||
* Flush the info in the string internal rep that refers to the
|
||||
* about-to-be-invalidated UTF-8 rep. This indicates that a new
|
||||
* buffer needs to be allocated, and assumes that the value is
|
||||
* already of tclStringTypePtr type, which should be true provided
|
||||
* we call it after Tcl_GetUnicodeFromObj.
|
||||
*/
|
||||
#define MarkStringInternalRepForFlush(objPtr) \
|
||||
(GET_STRING(objPtr)->allocated = 0)
|
||||
|
||||
if (Tcl_IsShared(valuePtr)) {
|
||||
objResultPtr = Tcl_DuplicateObj(valuePtr);
|
||||
} else {
|
||||
objResultPtr = valuePtr;
|
||||
}
|
||||
if (TclIsPureByteArray(objResultPtr)
|
||||
&& TclIsPureByteArray(value3Ptr)) {
|
||||
bytes1 = Tcl_GetByteArrayFromObj(objResultPtr, NULL);
|
||||
bytes2 = Tcl_GetByteArrayFromObj(value3Ptr, NULL);
|
||||
memcpy(bytes1 + fromIdx, bytes2, length3);
|
||||
} else {
|
||||
ustring1 = Tcl_GetUnicodeFromObj(objResultPtr, NULL);
|
||||
ustring2 = Tcl_GetUnicodeFromObj(value3Ptr, NULL);
|
||||
memcpy(ustring1 + fromIdx, ustring2,
|
||||
length3 * sizeof(Tcl_UniChar));
|
||||
}
|
||||
Tcl_InvalidateStringRep(objResultPtr);
|
||||
TclDecrRefCount(value3Ptr);
|
||||
TRACE_APPEND(("\"%.30s\"\n", O2S(objResultPtr)));
|
||||
if (objResultPtr == valuePtr) {
|
||||
NEXT_INST_F(1, 0, 0);
|
||||
} else {
|
||||
if (TclIsPureByteArray(objResultPtr)
|
||||
&& TclIsPureByteArray(value3Ptr)) {
|
||||
bytes1 = Tcl_GetByteArrayFromObj(objResultPtr, NULL);
|
||||
bytes2 = Tcl_GetByteArrayFromObj(value3Ptr, NULL);
|
||||
memcpy(bytes1 + fromIdx, bytes2, length3);
|
||||
} else {
|
||||
ustring1 = Tcl_GetUnicodeFromObj(objResultPtr, NULL);
|
||||
ustring2 = Tcl_GetUnicodeFromObj(value3Ptr, NULL);
|
||||
memcpy(ustring1 + fromIdx, ustring2,
|
||||
length3 * sizeof(Tcl_UniChar));
|
||||
MarkStringInternalRepForFlush(objResultPtr);
|
||||
}
|
||||
Tcl_InvalidateStringRep(objResultPtr);
|
||||
TclDecrRefCount(value3Ptr);
|
||||
TRACE_APPEND(("\"%.30s\"\n", O2S(objResultPtr)));
|
||||
NEXT_INST_F(1, 1, 1);
|
||||
} else {
|
||||
if (TclIsPureByteArray(valuePtr)
|
||||
&& TclIsPureByteArray(value3Ptr)) {
|
||||
bytes1 = Tcl_GetByteArrayFromObj(valuePtr, NULL);
|
||||
bytes2 = Tcl_GetByteArrayFromObj(value3Ptr, NULL);
|
||||
memcpy(bytes1 + fromIdx, bytes2, length3);
|
||||
} else {
|
||||
ustring1 = Tcl_GetUnicodeFromObj(valuePtr, NULL);
|
||||
ustring2 = Tcl_GetUnicodeFromObj(value3Ptr, NULL);
|
||||
memcpy(ustring1 + fromIdx, ustring2,
|
||||
length3 * sizeof(Tcl_UniChar));
|
||||
MarkStringInternalRepForFlush(valuePtr);
|
||||
}
|
||||
Tcl_InvalidateStringRep(valuePtr);
|
||||
TclDecrRefCount(value3Ptr);
|
||||
TRACE_APPEND(("\"%.30s\"\n", O2S(valuePtr)));
|
||||
NEXT_INST_F(1, 0, 0);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5621,38 +5791,54 @@ TEBCresume(
|
||||
* Remove substring using copying.
|
||||
*/
|
||||
|
||||
objResultPtr = NULL;
|
||||
if (fromIdx > 0) {
|
||||
objResultPtr = Tcl_NewUnicodeObj(ustring1, fromIdx);
|
||||
}
|
||||
if (length3 > 0) {
|
||||
if (objResultPtr) {
|
||||
Tcl_AppendObjToObj(objResultPtr, value3Ptr);
|
||||
} else if (Tcl_IsShared(value3Ptr)) {
|
||||
objResultPtr = Tcl_DuplicateObj(value3Ptr);
|
||||
} else {
|
||||
objResultPtr = value3Ptr;
|
||||
}
|
||||
}
|
||||
if (toIdx < length) {
|
||||
if (objResultPtr) {
|
||||
Tcl_AppendUnicodeToObj(objResultPtr, ustring1 + toIdx + 1,
|
||||
length - toIdx);
|
||||
if (length3 == 0) {
|
||||
if (fromIdx > 0) {
|
||||
objResultPtr = Tcl_NewUnicodeObj(ustring1, fromIdx);
|
||||
if (toIdx < length) {
|
||||
Tcl_AppendUnicodeToObj(objResultPtr, ustring1 + toIdx + 1,
|
||||
length - toIdx);
|
||||
}
|
||||
} else {
|
||||
objResultPtr = Tcl_NewUnicodeObj(ustring1 + toIdx + 1,
|
||||
length - toIdx);
|
||||
}
|
||||
TclDecrRefCount(value3Ptr);
|
||||
TRACE_APPEND(("\"%.30s\"\n", O2S(objResultPtr)));
|
||||
NEXT_INST_F(1, 1, 1);
|
||||
}
|
||||
if (objResultPtr == NULL) {
|
||||
/* This has to be the case [string replace $s 0 end {}] */
|
||||
/* which has result {} which is same as value3Ptr. */
|
||||
objResultPtr = value3Ptr;
|
||||
}
|
||||
if (objResultPtr == value3Ptr) {
|
||||
/* See [Bug 82e7f67325] */
|
||||
TclDecrRefCount(OBJ_AT_TOS);
|
||||
OBJ_AT_TOS = value3Ptr;
|
||||
|
||||
/*
|
||||
* Splice string pieces by full copying.
|
||||
*/
|
||||
|
||||
if (fromIdx > 0) {
|
||||
objResultPtr = Tcl_NewUnicodeObj(ustring1, fromIdx);
|
||||
Tcl_AppendObjToObj(objResultPtr, value3Ptr);
|
||||
if (toIdx < length) {
|
||||
Tcl_AppendUnicodeToObj(objResultPtr, ustring1 + toIdx + 1,
|
||||
length - toIdx);
|
||||
}
|
||||
} else if (Tcl_IsShared(value3Ptr)) {
|
||||
objResultPtr = Tcl_DuplicateObj(value3Ptr);
|
||||
if (toIdx < length) {
|
||||
Tcl_AppendUnicodeToObj(objResultPtr, ustring1 + toIdx + 1,
|
||||
length - toIdx);
|
||||
}
|
||||
} else {
|
||||
/*
|
||||
* Be careful with splicing the stack in this case; we have a
|
||||
* refCount:1 object in value3Ptr and we want to append to it and
|
||||
* make it be the refCount:1 object at the top of the stack
|
||||
* afterwards. [Bug 82e7f67325]
|
||||
*/
|
||||
|
||||
if (toIdx < length) {
|
||||
Tcl_AppendUnicodeToObj(value3Ptr, ustring1 + toIdx + 1,
|
||||
length - toIdx);
|
||||
}
|
||||
TRACE_APPEND(("\"%.30s\"\n", O2S(value3Ptr)));
|
||||
TclDecrRefCount(valuePtr);
|
||||
OBJ_AT_TOS = value3Ptr; /* Tricky! */
|
||||
NEXT_INST_F(1, 0, 0);
|
||||
}
|
||||
TclDecrRefCount(value3Ptr);
|
||||
@@ -5720,19 +5906,45 @@ TEBCresume(
|
||||
NEXT_INST_V(1, 3, 1);
|
||||
|
||||
case INST_STR_FIND:
|
||||
match = TclStringFind(OBJ_UNDER_TOS, OBJ_AT_TOS, 0);
|
||||
ustring1 = Tcl_GetUnicodeFromObj(OBJ_AT_TOS, &length); /* Haystack */
|
||||
ustring2 = Tcl_GetUnicodeFromObj(OBJ_UNDER_TOS, &length2);/* Needle */
|
||||
|
||||
match = -1;
|
||||
if (length2 > 0 && length2 <= length) {
|
||||
end = ustring1 + length - length2 + 1;
|
||||
for (p=ustring1 ; p<end ; p++) {
|
||||
if ((*p == *ustring2) &&
|
||||
memcmp(ustring2,p,sizeof(Tcl_UniChar)*length2) == 0) {
|
||||
match = p - ustring1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
TRACE(("%.20s %.20s => %d\n",
|
||||
O2S(OBJ_UNDER_TOS), O2S(OBJ_AT_TOS), match));
|
||||
TclNewLongObj(objResultPtr, match);
|
||||
TclNewIntObj(objResultPtr, match);
|
||||
NEXT_INST_F(1, 2, 1);
|
||||
|
||||
case INST_STR_FIND_LAST:
|
||||
match = TclStringLast(OBJ_UNDER_TOS, OBJ_AT_TOS, INT_MAX - 1);
|
||||
ustring1 = Tcl_GetUnicodeFromObj(OBJ_AT_TOS, &length); /* Haystack */
|
||||
ustring2 = Tcl_GetUnicodeFromObj(OBJ_UNDER_TOS, &length2);/* Needle */
|
||||
|
||||
match = -1;
|
||||
if (length2 > 0 && length2 <= length) {
|
||||
for (p=ustring1+length-length2 ; p>=ustring1 ; p--) {
|
||||
if ((*p == *ustring2) &&
|
||||
memcmp(ustring2,p,sizeof(Tcl_UniChar)*length2) == 0) {
|
||||
match = p - ustring1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
TRACE(("%.20s %.20s => %d\n",
|
||||
O2S(OBJ_UNDER_TOS), O2S(OBJ_AT_TOS), match));
|
||||
TclNewLongObj(objResultPtr, match);
|
||||
|
||||
TclNewIntObj(objResultPtr, match);
|
||||
NEXT_INST_F(1, 2, 1);
|
||||
|
||||
case INST_STR_CLASS:
|
||||
@@ -5936,7 +6148,7 @@ TEBCresume(
|
||||
type1 = TCL_NUMBER_WIDE;
|
||||
}
|
||||
}
|
||||
TclNewLongObj(objResultPtr, type1);
|
||||
TclNewIntObj(objResultPtr, type1);
|
||||
TRACE(("\"%.20s\" => %d\n", O2S(OBJ_AT_TOS), type1));
|
||||
NEXT_INST_F(1, 1, 1);
|
||||
|
||||
@@ -6143,7 +6355,7 @@ TEBCresume(
|
||||
if (l1 > 0L) {
|
||||
objResultPtr = TCONST(0);
|
||||
} else {
|
||||
TclNewLongObj(objResultPtr, -1);
|
||||
TclNewIntObj(objResultPtr, -1);
|
||||
}
|
||||
TRACE(("%s\n", O2S(objResultPtr)));
|
||||
NEXT_INST_F(1, 2, 1);
|
||||
@@ -7043,7 +7255,7 @@ TEBCresume(
|
||||
NEXT_INST_F(1, 0, -1);
|
||||
|
||||
case INST_PUSH_RETURN_CODE:
|
||||
TclNewLongObj(objResultPtr, result);
|
||||
TclNewIntObj(objResultPtr, result);
|
||||
TRACE(("=> %u\n", result));
|
||||
NEXT_INST_F(1, 0, 1);
|
||||
|
||||
@@ -8935,7 +9147,7 @@ ExecuteExtendedBinaryMathOp(
|
||||
}
|
||||
Tcl_TakeBignumFromObj(NULL, valuePtr, &big1);
|
||||
mp_init(&bigResult);
|
||||
mp_expt_d_ex(&big1, big2.dp[0], &bigResult, 1);
|
||||
mp_expt_d(&big1, big2.dp[0], &bigResult);
|
||||
mp_clear(&big1);
|
||||
mp_clear(&big2);
|
||||
BIG_RESULT(&bigResult);
|
||||
@@ -9459,9 +9671,9 @@ PrintByteCodeInfo(
|
||||
Proc *procPtr = codePtr->procPtr;
|
||||
Interp *iPtr = (Interp *) *codePtr->interpHandle;
|
||||
|
||||
fprintf(stdout, "\nExecuting ByteCode 0x%p, refCt %" TCL_LL_MODIFIER "u, epoch %" TCL_LL_MODIFIER "u, interp 0x%p (epoch %" TCL_LL_MODIFIER "u)\n",
|
||||
codePtr, (Tcl_WideInt)codePtr->refCount, (Tcl_WideInt)codePtr->compileEpoch, iPtr,
|
||||
(Tcl_WideInt)iPtr->compileEpoch);
|
||||
fprintf(stdout, "\nExecuting ByteCode 0x%p, refCt %u, epoch %u, interp 0x%p (epoch %u)\n",
|
||||
codePtr, codePtr->refCount, codePtr->compileEpoch, iPtr,
|
||||
iPtr->compileEpoch);
|
||||
|
||||
fprintf(stdout, " Source: ");
|
||||
TclPrintSource(stdout, codePtr->source, 60);
|
||||
@@ -9558,7 +9770,7 @@ ValidatePcAndStackTop(
|
||||
TclNewLiteralStringObj(message, "\n executing ");
|
||||
Tcl_IncrRefCount(message);
|
||||
Tcl_AppendLimitedToObj(message, cmd, numChars, 100, NULL);
|
||||
fprintf(stderr,"%s\n", TclGetString(message));
|
||||
fprintf(stderr,"%s\n", Tcl_GetString(message));
|
||||
Tcl_DecrRefCount(message);
|
||||
} else {
|
||||
fprintf(stderr, "\n");
|
||||
@@ -10021,7 +10233,7 @@ TclExprFloatError(
|
||||
"unknown floating-point error, errno = %d", errno);
|
||||
|
||||
Tcl_SetErrorCode(interp, "ARITH", "UNKNOWN",
|
||||
TclGetString(objPtr), NULL);
|
||||
Tcl_GetString(objPtr), NULL);
|
||||
Tcl_SetObjResult(interp, objPtr);
|
||||
}
|
||||
}
|
||||
|
||||
+2
-2
@@ -924,7 +924,7 @@ HashStringKey(
|
||||
*
|
||||
* BogusFind --
|
||||
*
|
||||
* This function is invoked when Tcl_FindHashEntry is called on a
|
||||
* This function is invoked when an Tcl_FindHashEntry is called on a
|
||||
* table that has been deleted.
|
||||
*
|
||||
* Results:
|
||||
@@ -951,7 +951,7 @@ BogusFind(
|
||||
*
|
||||
* BogusCreate --
|
||||
*
|
||||
* This function is invoked when Tcl_CreateHashEntry is called on a
|
||||
* This function is invoked when an Tcl_CreateHashEntry is called on a
|
||||
* table that has been deleted.
|
||||
*
|
||||
* Results:
|
||||
|
||||
+3
-3
@@ -323,7 +323,7 @@ typedef struct ResolvedChanName {
|
||||
Tcl_Interp *interp; /* The interp in which the lookup was done. */
|
||||
int epoch; /* The epoch of the channel when the lookup
|
||||
* was done. Use to verify validity. */
|
||||
size_t refCount; /* Share this struct among many Tcl_Obj. */
|
||||
int refCount; /* Share this struct among many Tcl_Obj. */
|
||||
} ResolvedChanName;
|
||||
|
||||
static void DupChannelIntRep(Tcl_Obj *objPtr, Tcl_Obj *copyPtr);
|
||||
@@ -7129,7 +7129,7 @@ Tcl_Tell(
|
||||
*
|
||||
* Tcl_SeekOld, Tcl_TellOld --
|
||||
*
|
||||
* Backward-compatibility versions of the seek/tell interface that do not
|
||||
* Backward-compatability versions of the seek/tell interface that do not
|
||||
* support 64-bit offsets. This interface is not documented or expected
|
||||
* to be supported indefinitely.
|
||||
*
|
||||
@@ -11194,7 +11194,7 @@ FreeChannelIntRep(
|
||||
ResolvedChanName *resPtr = objPtr->internalRep.twoPtrValue.ptr1;
|
||||
|
||||
objPtr->typePtr = NULL;
|
||||
if (resPtr->refCount-- > 1) {
|
||||
if (--resPtr->refCount) {
|
||||
return;
|
||||
}
|
||||
Tcl_Release(resPtr->statePtr);
|
||||
|
||||
+2
-2
@@ -211,7 +211,7 @@ struct TransformChannelData {
|
||||
* a transformation of incoming data. Also
|
||||
* serves as buffer of all data not yet
|
||||
* consumed by the reader. */
|
||||
size_t refCount;
|
||||
int refCount;
|
||||
};
|
||||
|
||||
static void
|
||||
@@ -225,7 +225,7 @@ static void
|
||||
ReleaseData(
|
||||
TransformChannelData *dataPtr)
|
||||
{
|
||||
if (dataPtr->refCount-- > 1) {
|
||||
if (--dataPtr->refCount) {
|
||||
return;
|
||||
}
|
||||
ResultClear(&dataPtr->result);
|
||||
|
||||
@@ -591,7 +591,7 @@ TclChanCreateObjCmd(
|
||||
if (Tcl_ListObjGetElements(NULL, resObj, &listc, &listv) != TCL_OK) {
|
||||
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
|
||||
"chan handler \"%s initialize\" returned non-list: %s",
|
||||
TclGetString(cmdObj), TclGetString(resObj)));
|
||||
Tcl_GetString(cmdObj), Tcl_GetString(resObj)));
|
||||
Tcl_DecrRefCount(resObj);
|
||||
goto error;
|
||||
}
|
||||
@@ -617,35 +617,35 @@ TclChanCreateObjCmd(
|
||||
if ((REQUIRED_METHODS & methods) != REQUIRED_METHODS) {
|
||||
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
|
||||
"chan handler \"%s\" does not support all required methods",
|
||||
TclGetString(cmdObj)));
|
||||
Tcl_GetString(cmdObj)));
|
||||
goto error;
|
||||
}
|
||||
|
||||
if ((mode & TCL_READABLE) && !HAS(methods, METH_READ)) {
|
||||
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
|
||||
"chan handler \"%s\" lacks a \"read\" method",
|
||||
TclGetString(cmdObj)));
|
||||
Tcl_GetString(cmdObj)));
|
||||
goto error;
|
||||
}
|
||||
|
||||
if ((mode & TCL_WRITABLE) && !HAS(methods, METH_WRITE)) {
|
||||
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
|
||||
"chan handler \"%s\" lacks a \"write\" method",
|
||||
TclGetString(cmdObj)));
|
||||
Tcl_GetString(cmdObj)));
|
||||
goto error;
|
||||
}
|
||||
|
||||
if (!IMPLIES(HAS(methods, METH_CGET), HAS(methods, METH_CGETALL))) {
|
||||
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
|
||||
"chan handler \"%s\" supports \"cget\" but not \"cgetall\"",
|
||||
TclGetString(cmdObj)));
|
||||
Tcl_GetString(cmdObj)));
|
||||
goto error;
|
||||
}
|
||||
|
||||
if (!IMPLIES(HAS(methods, METH_CGETALL), HAS(methods, METH_CGET))) {
|
||||
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
|
||||
"chan handler \"%s\" supports \"cgetall\" but not \"cget\"",
|
||||
TclGetString(cmdObj)));
|
||||
Tcl_GetString(cmdObj)));
|
||||
goto error;
|
||||
}
|
||||
|
||||
@@ -1152,7 +1152,7 @@ ReflectClose(
|
||||
|
||||
tctPtr = ((Channel *)rcPtr->chan)->typePtr;
|
||||
if (tctPtr && tctPtr != &tclRChannelType) {
|
||||
ckfree(tctPtr);
|
||||
ckfree((char *)tctPtr);
|
||||
((Channel *)rcPtr->chan)->typePtr = NULL;
|
||||
}
|
||||
Tcl_EventuallyFree(rcPtr, (Tcl_FreeProc *) FreeReflectedChannel);
|
||||
@@ -1221,7 +1221,7 @@ ReflectClose(
|
||||
#endif
|
||||
tctPtr = ((Channel *)rcPtr->chan)->typePtr;
|
||||
if (tctPtr && tctPtr != &tclRChannelType) {
|
||||
ckfree(tctPtr);
|
||||
ckfree((char *)tctPtr);
|
||||
((Channel *)rcPtr->chan)->typePtr = NULL;
|
||||
}
|
||||
Tcl_EventuallyFree(rcPtr, (Tcl_FreeProc *) FreeReflectedChannel);
|
||||
@@ -2398,7 +2398,7 @@ ErrnoReturn(
|
||||
|
||||
if (((Tcl_GetIntFromObj(rcPtr->interp, resObj, &code) != TCL_OK)
|
||||
|| (code >= 0))) {
|
||||
if (strcmp("EAGAIN", TclGetString(resObj)) == 0) {
|
||||
if (strcmp("EAGAIN", Tcl_GetString(resObj)) == 0) {
|
||||
code = -EAGAIN;
|
||||
} else {
|
||||
code = 0;
|
||||
|
||||
+13
-13
@@ -554,7 +554,7 @@ TclChanPushObjCmd(
|
||||
*/
|
||||
|
||||
chanObj = objv[CHAN];
|
||||
parentChan = Tcl_GetChannel(interp, TclGetString(chanObj), &mode);
|
||||
parentChan = Tcl_GetChannel(interp, Tcl_GetString(chanObj), &mode);
|
||||
if (parentChan == NULL) {
|
||||
return TCL_ERROR;
|
||||
}
|
||||
@@ -608,7 +608,7 @@ TclChanPushObjCmd(
|
||||
if (Tcl_ListObjGetElements(NULL, resObj, &listc, &listv) != TCL_OK) {
|
||||
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
|
||||
"chan handler \"%s initialize\" returned non-list: %s",
|
||||
TclGetString(cmdObj), TclGetString(resObj)));
|
||||
Tcl_GetString(cmdObj), Tcl_GetString(resObj)));
|
||||
Tcl_DecrRefCount(resObj);
|
||||
goto error;
|
||||
}
|
||||
@@ -619,7 +619,7 @@ TclChanPushObjCmd(
|
||||
"method", TCL_EXACT, &methIndex) != TCL_OK) {
|
||||
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
|
||||
"chan handler \"%s initialize\" returned %s",
|
||||
TclGetString(cmdObj),
|
||||
Tcl_GetString(cmdObj),
|
||||
Tcl_GetString(Tcl_GetObjResult(interp))));
|
||||
Tcl_DecrRefCount(resObj);
|
||||
goto error;
|
||||
@@ -633,7 +633,7 @@ TclChanPushObjCmd(
|
||||
if ((REQUIRED_METHODS & methods) != REQUIRED_METHODS) {
|
||||
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
|
||||
"chan handler \"%s\" does not support all required methods",
|
||||
TclGetString(cmdObj)));
|
||||
Tcl_GetString(cmdObj)));
|
||||
goto error;
|
||||
}
|
||||
|
||||
@@ -655,7 +655,7 @@ TclChanPushObjCmd(
|
||||
if (!mode) {
|
||||
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
|
||||
"chan handler \"%s\" makes the channel inaccessible",
|
||||
TclGetString(cmdObj)));
|
||||
Tcl_GetString(cmdObj)));
|
||||
goto error;
|
||||
}
|
||||
|
||||
@@ -666,14 +666,14 @@ TclChanPushObjCmd(
|
||||
if (!IMPLIES(HAS(methods, METH_DRAIN), HAS(methods, METH_READ))) {
|
||||
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
|
||||
"chan handler \"%s\" supports \"drain\" but not \"read\"",
|
||||
TclGetString(cmdObj)));
|
||||
Tcl_GetString(cmdObj)));
|
||||
goto error;
|
||||
}
|
||||
|
||||
if (!IMPLIES(HAS(methods, METH_FLUSH), HAS(methods, METH_WRITE))) {
|
||||
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
|
||||
"chan handler \"%s\" supports \"flush\" but not \"write\"",
|
||||
TclGetString(cmdObj)));
|
||||
Tcl_GetString(cmdObj)));
|
||||
goto error;
|
||||
}
|
||||
|
||||
@@ -694,14 +694,14 @@ TclChanPushObjCmd(
|
||||
*/
|
||||
|
||||
rtmPtr = GetReflectedTransformMap(interp);
|
||||
hPtr = Tcl_CreateHashEntry(&rtmPtr->map, TclGetString(rtId), &isNew);
|
||||
hPtr = Tcl_CreateHashEntry(&rtmPtr->map, Tcl_GetString(rtId), &isNew);
|
||||
if (!isNew && rtPtr != Tcl_GetHashValue(hPtr)) {
|
||||
Tcl_Panic("TclChanPushObjCmd: duplicate transformation handle");
|
||||
}
|
||||
Tcl_SetHashValue(hPtr, rtPtr);
|
||||
#ifdef TCL_THREADS
|
||||
rtmPtr = GetThreadReflectedTransformMap();
|
||||
hPtr = Tcl_CreateHashEntry(&rtmPtr->map, TclGetString(rtId), &isNew);
|
||||
hPtr = Tcl_CreateHashEntry(&rtmPtr->map, Tcl_GetString(rtId), &isNew);
|
||||
Tcl_SetHashValue(hPtr, rtPtr);
|
||||
#endif /* TCL_THREADS */
|
||||
|
||||
@@ -1027,7 +1027,7 @@ ReflectClose(
|
||||
|
||||
#ifdef TCL_THREADS
|
||||
rtmPtr = GetThreadReflectedTransformMap();
|
||||
hPtr = Tcl_FindHashEntry(&rtmPtr->map, TclGetString(rtPtr->handle));
|
||||
hPtr = Tcl_FindHashEntry(&rtmPtr->map, Tcl_GetString(rtPtr->handle));
|
||||
if (hPtr) {
|
||||
Tcl_DeleteHashEntry(hPtr);
|
||||
}
|
||||
@@ -2568,7 +2568,7 @@ ForwardProc(
|
||||
*/
|
||||
|
||||
rtmPtr = GetReflectedTransformMap(interp);
|
||||
hPtr = Tcl_FindHashEntry(&rtmPtr->map, TclGetString(rtPtr->handle));
|
||||
hPtr = Tcl_FindHashEntry(&rtmPtr->map, Tcl_GetString(rtPtr->handle));
|
||||
Tcl_DeleteHashEntry(hPtr);
|
||||
|
||||
/*
|
||||
@@ -2578,7 +2578,7 @@ ForwardProc(
|
||||
*/
|
||||
|
||||
rtmPtr = GetThreadReflectedTransformMap();
|
||||
hPtr = Tcl_FindHashEntry(&rtmPtr->map, TclGetString(rtPtr->handle));
|
||||
hPtr = Tcl_FindHashEntry(&rtmPtr->map, Tcl_GetString(rtPtr->handle));
|
||||
Tcl_DeleteHashEntry(hPtr);
|
||||
|
||||
FreeReflectedTransformArgs(rtPtr);
|
||||
@@ -2955,7 +2955,7 @@ ResultClear(
|
||||
return;
|
||||
}
|
||||
|
||||
ckfree(rPtr->buf);
|
||||
ckfree((char *) rPtr->buf);
|
||||
rPtr->buf = NULL;
|
||||
rPtr->allocated = 0;
|
||||
}
|
||||
|
||||
+24
-26
@@ -56,8 +56,8 @@ static const char *gai_strerror(int code) {
|
||||
int
|
||||
TclSockGetPort(
|
||||
Tcl_Interp *interp,
|
||||
const char *string, /* Integer or service name */
|
||||
const char *proto, /* "tcp" or "udp", typically */
|
||||
const char *string, /* Integer or service name */
|
||||
const char *proto, /* "tcp" or "udp", typically */
|
||||
int *portPtr) /* Return port number */
|
||||
{
|
||||
struct servent *sp; /* Protocol info for named services */
|
||||
@@ -154,15 +154,15 @@ TclSockMinimumBuffers(
|
||||
|
||||
int
|
||||
TclCreateSocketAddress(
|
||||
Tcl_Interp *interp, /* Interpreter for querying the desired socket
|
||||
* family */
|
||||
struct addrinfo **addrlist, /* Socket address list */
|
||||
const char *host, /* Host. NULL implies INADDR_ANY */
|
||||
int port, /* Port number */
|
||||
int willBind, /* Is this an address to bind() to or to
|
||||
* connect() to? */
|
||||
const char **errorMsgPtr) /* Place to store the error message detail, if
|
||||
* available. */
|
||||
Tcl_Interp *interp, /* Interpreter for querying
|
||||
* the desired socket family */
|
||||
struct addrinfo **addrlist, /* Socket address list */
|
||||
const char *host, /* Host. NULL implies INADDR_ANY */
|
||||
int port, /* Port number */
|
||||
int willBind, /* Is this an address to bind() to or
|
||||
* to connect() to? */
|
||||
const char **errorMsgPtr) /* Place to store the error message
|
||||
* detail, if available. */
|
||||
{
|
||||
struct addrinfo hints;
|
||||
struct addrinfo *p;
|
||||
@@ -181,31 +181,30 @@ TclCreateSocketAddress(
|
||||
* Workaround for OSX's apparent inability to resolve "localhost", "0"
|
||||
* when the loopback device is the only available network interface.
|
||||
*/
|
||||
|
||||
if (host != NULL && port == 0) {
|
||||
portstring = NULL;
|
||||
portstring = NULL;
|
||||
} else {
|
||||
TclFormatInt(portbuf, port);
|
||||
portstring = portbuf;
|
||||
TclFormatInt(portbuf, port);
|
||||
portstring = portbuf;
|
||||
}
|
||||
|
||||
(void) memset(&hints, 0, sizeof(hints));
|
||||
hints.ai_family = AF_UNSPEC;
|
||||
|
||||
/*
|
||||
* Magic variable to enforce a certain address family; to be superseded
|
||||
* by a TIP that adds explicit switches to [socket].
|
||||
* Magic variable to enforce a certain address family - to be superseded
|
||||
* by a TIP that adds explicit switches to [socket]
|
||||
*/
|
||||
|
||||
if (interp != NULL) {
|
||||
family = Tcl_GetVar2(interp, "::tcl::unsupported::socketAF", NULL, 0);
|
||||
if (family != NULL) {
|
||||
if (strcmp(family, "inet") == 0) {
|
||||
hints.ai_family = AF_INET;
|
||||
} else if (strcmp(family, "inet6") == 0) {
|
||||
hints.ai_family = AF_INET6;
|
||||
}
|
||||
}
|
||||
family = Tcl_GetVar2(interp, "::tcl::unsupported::socketAF", NULL, 0);
|
||||
if (family != NULL) {
|
||||
if (strcmp(family, "inet") == 0) {
|
||||
hints.ai_family = AF_INET;
|
||||
} else if (strcmp(family, "inet6") == 0) {
|
||||
hints.ai_family = AF_INET6;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
hints.ai_socktype = SOCK_STREAM;
|
||||
@@ -252,7 +251,6 @@ TclCreateSocketAddress(
|
||||
*
|
||||
* There might be more elegant/efficient ways to do this.
|
||||
*/
|
||||
|
||||
if (willBind) {
|
||||
for (p = *addrlist; p != NULL; p = p->ai_next) {
|
||||
if (p->ai_family == AF_INET) {
|
||||
|
||||
+2
-2
@@ -638,8 +638,8 @@ FsGetFirstFilesystem(void)
|
||||
}
|
||||
|
||||
/*
|
||||
* The epoch can be changed by filesystems being added or removed, by changing
|
||||
* the "system encoding" and by env(HOME) changing.
|
||||
* The epoch can be changed both by filesystems being added or removed and by
|
||||
* env(HOME) changing.
|
||||
*/
|
||||
|
||||
int
|
||||
|
||||
@@ -1009,7 +1009,7 @@ declare 250 {
|
||||
# Allow extensions for optimization
|
||||
declare 251 {
|
||||
int TclRegisterLiteral(void *envPtr,
|
||||
const char *bytes, int length, int flags)
|
||||
char *bytes, int length, int flags)
|
||||
}
|
||||
|
||||
##############################################################################
|
||||
@@ -1246,7 +1246,7 @@ declare 19 macosx {
|
||||
}
|
||||
|
||||
declare 29 {win unix} {
|
||||
int TclWinCPUID(int index, int *regs)
|
||||
int TclWinCPUID(unsigned int index, unsigned int *regs)
|
||||
}
|
||||
# Added in 8.6; core of TclpOpenTemporaryFile
|
||||
declare 30 {win unix} {
|
||||
|
||||
+29
-36
@@ -804,7 +804,6 @@ typedef struct VarInHash {
|
||||
* MODULE_SCOPE int TclIsVarTemporary(Var *varPtr);
|
||||
* MODULE_SCOPE int TclIsVarArgument(Var *varPtr);
|
||||
* MODULE_SCOPE int TclIsVarResolved(Var *varPtr);
|
||||
* MODULE_SCOPE int TclIsVarArraySearched(Var *varPtr);
|
||||
*/
|
||||
|
||||
#define TclIsVarScalar(varPtr) \
|
||||
@@ -846,9 +845,6 @@ typedef struct VarInHash {
|
||||
#define TclIsVarDeadHash(varPtr) \
|
||||
((varPtr)->flags & VAR_DEAD_HASH)
|
||||
|
||||
#define TclIsVarArraySearched(varPtr) \
|
||||
((varPtr)->flags & VAR_SEARCH_ACTIVE)
|
||||
|
||||
#define TclGetVarNsPtr(varPtr) \
|
||||
(TclIsVarInHash(varPtr) \
|
||||
? ((TclVarHashTable *) ((((VarInHash *) (varPtr))->entry.tablePtr)))->nsPtr \
|
||||
@@ -1694,13 +1690,11 @@ typedef struct Command {
|
||||
* (these last two flags are defined in tcl.h)
|
||||
*/
|
||||
|
||||
#define CMD_IS_DELETED 0x01
|
||||
#define CMD_TRACE_ACTIVE 0x02
|
||||
#define CMD_HAS_EXEC_TRACES 0x04
|
||||
#define CMD_COMPILES_EXPANDED 0x08
|
||||
#define CMD_IS_DELETED 0x1
|
||||
#define CMD_TRACE_ACTIVE 0x2
|
||||
#define CMD_HAS_EXEC_TRACES 0x4
|
||||
#define CMD_COMPILES_EXPANDED 0x8
|
||||
#define CMD_REDEF_IN_PROGRESS 0x10
|
||||
#define CMD_VIA_RESOLVER 0x20
|
||||
|
||||
|
||||
/*
|
||||
*----------------------------------------------------------------
|
||||
@@ -1902,7 +1896,7 @@ typedef struct Interp {
|
||||
* compiled by the interpreter. Indexed by the
|
||||
* string representations of literals. Used to
|
||||
* avoid creating duplicate objects. */
|
||||
unsigned int compileEpoch; /* Holds the current "compilation epoch" for
|
||||
int compileEpoch; /* Holds the current "compilation epoch" for
|
||||
* this interpreter. This is incremented to
|
||||
* invalidate existing ByteCodes when, e.g., a
|
||||
* command with a compile procedure is
|
||||
@@ -2612,7 +2606,7 @@ typedef Tcl_ObjCmdProc *TclObjCmdProcType;
|
||||
*----------------------------------------------------------------
|
||||
*/
|
||||
|
||||
typedef void (TclInitProcessGlobalValueProc)(char **valuePtr, size_t *lengthPtr,
|
||||
typedef void (TclInitProcessGlobalValueProc)(char **valuePtr, int *lengthPtr,
|
||||
Tcl_Encoding *encodingPtr);
|
||||
|
||||
/*
|
||||
@@ -2624,9 +2618,9 @@ typedef void (TclInitProcessGlobalValueProc)(char **valuePtr, size_t *lengthPtr,
|
||||
*/
|
||||
|
||||
typedef struct ProcessGlobalValue {
|
||||
size_t epoch; /* Epoch counter to detect changes in the
|
||||
int epoch; /* Epoch counter to detect changes in the
|
||||
* master value. */
|
||||
size_t numBytes; /* Length of the master string. */
|
||||
int numBytes; /* Length of the master string. */
|
||||
char *value; /* The master string value. */
|
||||
Tcl_Encoding encoding; /* system encoding when master string was
|
||||
* initialized. */
|
||||
@@ -3076,7 +3070,7 @@ MODULE_SCOPE int TclpThreadCreate(Tcl_ThreadId *idPtr,
|
||||
int stackSize, int flags);
|
||||
MODULE_SCOPE int TclpFindVariable(const char *name, int *lengthPtr);
|
||||
MODULE_SCOPE void TclpInitLibraryPath(char **valuePtr,
|
||||
size_t *lengthPtr, Tcl_Encoding *encodingPtr);
|
||||
int *lengthPtr, Tcl_Encoding *encodingPtr);
|
||||
MODULE_SCOPE void TclpInitLock(void);
|
||||
MODULE_SCOPE void TclpInitPlatform(void);
|
||||
MODULE_SCOPE void TclpInitUnlock(void);
|
||||
@@ -3139,20 +3133,11 @@ MODULE_SCOPE void TclSpellFix(Tcl_Interp *interp,
|
||||
Tcl_Obj *bad, Tcl_Obj *fix);
|
||||
MODULE_SCOPE void * TclStackRealloc(Tcl_Interp *interp, void *ptr,
|
||||
int numBytes);
|
||||
MODULE_SCOPE int TclStringCatObjv(Tcl_Interp *interp, int inPlace,
|
||||
int objc, Tcl_Obj *const objv[],
|
||||
Tcl_Obj **objPtrPtr);
|
||||
MODULE_SCOPE int TclStringFind(Tcl_Obj *needle, Tcl_Obj *haystack,
|
||||
int start);
|
||||
MODULE_SCOPE int TclStringLast(Tcl_Obj *needle, Tcl_Obj *haystack,
|
||||
int last);
|
||||
MODULE_SCOPE int TclStringMatch(const char *str, int strLen,
|
||||
const char *pattern, int ptnLen, int flags);
|
||||
MODULE_SCOPE int TclStringMatchObj(Tcl_Obj *stringObj,
|
||||
Tcl_Obj *patternObj, int flags);
|
||||
MODULE_SCOPE Tcl_Obj * TclStringObjReverse(Tcl_Obj *objPtr);
|
||||
MODULE_SCOPE int TclStringRepeat(Tcl_Interp *interp, Tcl_Obj *objPtr,
|
||||
int count, Tcl_Obj **objPtrPtr);
|
||||
MODULE_SCOPE void TclSubstCompile(Tcl_Interp *interp, const char *bytes,
|
||||
int numBytes, int flags, int line,
|
||||
struct CompileEnv *envPtr);
|
||||
@@ -4080,7 +4065,7 @@ typedef const char *TclDTraceStr;
|
||||
TCL_DTRACE_OBJ_FREE(objPtr); \
|
||||
if ((objPtr)->bytes \
|
||||
&& ((objPtr)->bytes != tclEmptyStringRep)) { \
|
||||
ckfree((objPtr)->bytes); \
|
||||
ckfree((char *) (objPtr)->bytes); \
|
||||
} \
|
||||
(objPtr)->length = -1; \
|
||||
TclFreeObjStorage(objPtr); \
|
||||
@@ -4103,7 +4088,7 @@ typedef const char *TclDTraceStr;
|
||||
(objPtr) = (Tcl_Obj *) ckalloc(sizeof(Tcl_Obj))
|
||||
|
||||
# define TclFreeObjStorageEx(interp, objPtr) \
|
||||
ckfree(objPtr)
|
||||
ckfree((char *) (objPtr))
|
||||
|
||||
#undef USE_THREAD_ALLOC
|
||||
#undef USE_TCLALLOC
|
||||
@@ -4262,7 +4247,7 @@ MODULE_SCOPE void TclDbInitNewObj(Tcl_Obj *objPtr, const char *file,
|
||||
*/
|
||||
|
||||
#define TclGetString(objPtr) \
|
||||
((objPtr)->bytes? (objPtr)->bytes : Tcl_GetString(objPtr))
|
||||
((objPtr)->bytes? (objPtr)->bytes : Tcl_GetString((objPtr)))
|
||||
|
||||
#define TclGetStringFromObj(objPtr, lenPtr) \
|
||||
((objPtr)->bytes \
|
||||
@@ -4297,11 +4282,11 @@ MODULE_SCOPE void TclDbInitNewObj(Tcl_Obj *objPtr, const char *file,
|
||||
*/
|
||||
|
||||
#define TclInvalidateStringRep(objPtr) \
|
||||
if ((objPtr)->bytes != NULL) { \
|
||||
if ((objPtr)->bytes != tclEmptyStringRep) { \
|
||||
ckfree((objPtr)->bytes); \
|
||||
if (objPtr->bytes != NULL) { \
|
||||
if (objPtr->bytes != tclEmptyStringRep) { \
|
||||
ckfree((char *) objPtr->bytes); \
|
||||
} \
|
||||
(objPtr)->bytes = NULL; \
|
||||
objPtr->bytes = NULL; \
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -4431,7 +4416,8 @@ MODULE_SCOPE void TclDbInitNewObj(Tcl_Obj *objPtr, const char *file,
|
||||
*----------------------------------------------------------------
|
||||
*/
|
||||
|
||||
MODULE_SCOPE int TclIsPureByteArray(Tcl_Obj *objPtr);
|
||||
#define TclIsPureByteArray(objPtr) \
|
||||
(((objPtr)->typePtr==&tclByteArrayType) && ((objPtr)->bytes==NULL))
|
||||
|
||||
/*
|
||||
*----------------------------------------------------------------
|
||||
@@ -4566,12 +4552,13 @@ MODULE_SCOPE Tcl_PackageInitProc Procbodytest_SafeInit;
|
||||
* types, avoiding the corresponding function calls in time critical parts of
|
||||
* the core. The ANSI C "prototypes" for these macros are:
|
||||
*
|
||||
* MODULE_SCOPE void TclNewIntObj(Tcl_Obj *objPtr, int i);
|
||||
* MODULE_SCOPE void TclNewLongObj(Tcl_Obj *objPtr, long l);
|
||||
* MODULE_SCOPE void TclNewBooleanObj(Tcl_Obj *objPtr, int b);
|
||||
* MODULE_SCOPE void TclNewWideObj(Tcl_Obj *objPtr, Tcl_WideInt w);
|
||||
* MODULE_SCOPE void TclNewDoubleObj(Tcl_Obj *objPtr, double d);
|
||||
* MODULE_SCOPE void TclNewStringObj(Tcl_Obj *objPtr, const char *s, int len);
|
||||
* MODULE_SCOPE void TclNewLiteralStringObj(Tcl_Obj*objPtr, const char *sLiteral);
|
||||
* MODULE_SCOPE void TclNewStringObj(Tcl_Obj *objPtr, char *s, int len);
|
||||
* MODULE_SCOPE void TclNewLiteralStringObj(Tcl_Obj*objPtr, char*sLiteral);
|
||||
*
|
||||
*----------------------------------------------------------------
|
||||
*/
|
||||
@@ -4588,6 +4575,9 @@ MODULE_SCOPE Tcl_PackageInitProc Procbodytest_SafeInit;
|
||||
TCL_DTRACE_OBJ_CREATE(objPtr); \
|
||||
} while (0)
|
||||
|
||||
#define TclNewIntObj(objPtr, l) \
|
||||
TclNewLongObj(objPtr, l)
|
||||
|
||||
/*
|
||||
* NOTE: There is to be no such thing as a "pure" boolean.
|
||||
* See comment above TclSetBooleanObj macro above.
|
||||
@@ -4617,6 +4607,9 @@ MODULE_SCOPE Tcl_PackageInitProc Procbodytest_SafeInit;
|
||||
} while (0)
|
||||
|
||||
#else /* TCL_MEM_DEBUG */
|
||||
#define TclNewIntObj(objPtr, i) \
|
||||
(objPtr) = Tcl_NewIntObj(i)
|
||||
|
||||
#define TclNewLongObj(objPtr, l) \
|
||||
(objPtr) = Tcl_NewLongObj(l)
|
||||
|
||||
@@ -4704,7 +4697,7 @@ MODULE_SCOPE Tcl_PackageInitProc Procbodytest_SafeInit;
|
||||
|
||||
#define TclCleanupCommandMacro(cmdPtr) \
|
||||
if ((cmdPtr)->refCount-- <= 1) { \
|
||||
ckfree(cmdPtr);\
|
||||
ckfree((char *) (cmdPtr));\
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -4862,7 +4855,7 @@ typedef struct NRE_callback {
|
||||
#else
|
||||
#define TCLNR_ALLOC(interp, ptr) \
|
||||
(ptr = ((ClientData) ckalloc(sizeof(NRE_callback))))
|
||||
#define TCLNR_FREE(interp, ptr) ckfree(ptr)
|
||||
#define TCLNR_FREE(interp, ptr) ckfree((char *) (ptr))
|
||||
#endif
|
||||
|
||||
#if NRE_ENABLE_ASSERTS
|
||||
|
||||
@@ -615,7 +615,7 @@ EXTERN char * TclDoubleDigits(double dv, int ndigits, int flags,
|
||||
EXTERN void TclSetSlaveCancelFlags(Tcl_Interp *interp, int flags,
|
||||
int force);
|
||||
/* 251 */
|
||||
EXTERN int TclRegisterLiteral(void *envPtr, const char *bytes,
|
||||
EXTERN int TclRegisterLiteral(void *envPtr, char *bytes,
|
||||
int length, int flags);
|
||||
|
||||
typedef struct TclIntStubs {
|
||||
@@ -873,7 +873,7 @@ typedef struct TclIntStubs {
|
||||
int (*tclCopyChannel) (Tcl_Interp *interp, Tcl_Channel inChan, Tcl_Channel outChan, Tcl_WideInt toRead, Tcl_Obj *cmdPtr); /* 248 */
|
||||
char * (*tclDoubleDigits) (double dv, int ndigits, int flags, int *decpt, int *signum, char **endPtr); /* 249 */
|
||||
void (*tclSetSlaveCancelFlags) (Tcl_Interp *interp, int flags, int force); /* 250 */
|
||||
int (*tclRegisterLiteral) (void *envPtr, const char *bytes, int length, int flags); /* 251 */
|
||||
int (*tclRegisterLiteral) (void *envPtr, char *bytes, int length, int flags); /* 251 */
|
||||
} TclIntStubs;
|
||||
|
||||
extern const TclIntStubs *tclIntStubsPtr;
|
||||
|
||||
@@ -98,7 +98,7 @@ EXTERN int TclUnixCopyFile(const char *src, const char *dst,
|
||||
/* Slot 27 is reserved */
|
||||
/* Slot 28 is reserved */
|
||||
/* 29 */
|
||||
EXTERN int TclWinCPUID(int index, int *regs);
|
||||
EXTERN int TclWinCPUID(unsigned int index, unsigned int *regs);
|
||||
/* 30 */
|
||||
EXTERN int TclUnixOpenTemporaryFile(Tcl_Obj *dirObj,
|
||||
Tcl_Obj *basenameObj, Tcl_Obj *extensionObj,
|
||||
@@ -173,7 +173,7 @@ EXTERN void TclWinFlushDirtyChannels(void);
|
||||
/* 28 */
|
||||
EXTERN void TclWinResetInterfaces(void);
|
||||
/* 29 */
|
||||
EXTERN int TclWinCPUID(int index, int *regs);
|
||||
EXTERN int TclWinCPUID(unsigned int index, unsigned int *regs);
|
||||
/* 30 */
|
||||
EXTERN int TclUnixOpenTemporaryFile(Tcl_Obj *dirObj,
|
||||
Tcl_Obj *basenameObj, Tcl_Obj *extensionObj,
|
||||
@@ -247,7 +247,7 @@ EXTERN void TclMacOSXNotifierAddRunLoopMode(
|
||||
/* Slot 27 is reserved */
|
||||
/* Slot 28 is reserved */
|
||||
/* 29 */
|
||||
EXTERN int TclWinCPUID(int index, int *regs);
|
||||
EXTERN int TclWinCPUID(unsigned int index, unsigned int *regs);
|
||||
/* 30 */
|
||||
EXTERN int TclUnixOpenTemporaryFile(Tcl_Obj *dirObj,
|
||||
Tcl_Obj *basenameObj, Tcl_Obj *extensionObj,
|
||||
@@ -288,7 +288,7 @@ typedef struct TclIntPlatStubs {
|
||||
void (*reserved26)(void);
|
||||
void (*reserved27)(void);
|
||||
void (*reserved28)(void);
|
||||
int (*tclWinCPUID) (int index, int *regs); /* 29 */
|
||||
int (*tclWinCPUID) (unsigned int index, unsigned int *regs); /* 29 */
|
||||
int (*tclUnixOpenTemporaryFile) (Tcl_Obj *dirObj, Tcl_Obj *basenameObj, Tcl_Obj *extensionObj, Tcl_Obj *resultingNameObj); /* 30 */
|
||||
#endif /* UNIX */
|
||||
#if defined(_WIN32) || defined(__CYGWIN__) /* WIN */
|
||||
@@ -321,7 +321,7 @@ typedef struct TclIntPlatStubs {
|
||||
void (*tclWinSetInterfaces) (int wide); /* 26 */
|
||||
void (*tclWinFlushDirtyChannels) (void); /* 27 */
|
||||
void (*tclWinResetInterfaces) (void); /* 28 */
|
||||
int (*tclWinCPUID) (int index, int *regs); /* 29 */
|
||||
int (*tclWinCPUID) (unsigned int index, unsigned int *regs); /* 29 */
|
||||
int (*tclUnixOpenTemporaryFile) (Tcl_Obj *dirObj, Tcl_Obj *basenameObj, Tcl_Obj *extensionObj, Tcl_Obj *resultingNameObj); /* 30 */
|
||||
#endif /* WIN */
|
||||
#ifdef MAC_OSX_TCL /* MACOSX */
|
||||
@@ -354,7 +354,7 @@ typedef struct TclIntPlatStubs {
|
||||
void (*reserved26)(void);
|
||||
void (*reserved27)(void);
|
||||
void (*reserved28)(void);
|
||||
int (*tclWinCPUID) (int index, int *regs); /* 29 */
|
||||
int (*tclWinCPUID) (unsigned int index, unsigned int *regs); /* 29 */
|
||||
int (*tclUnixOpenTemporaryFile) (Tcl_Obj *dirObj, Tcl_Obj *basenameObj, Tcl_Obj *extensionObj, Tcl_Obj *resultingNameObj); /* 30 */
|
||||
#endif /* MACOSX */
|
||||
} TclIntPlatStubs;
|
||||
|
||||
+8
-4
@@ -410,7 +410,6 @@ Tcl_Init(
|
||||
" {file join $grandParentDir lib tcl[info tclversion]} \\\n"
|
||||
" {file join $parentDir library} \\\n"
|
||||
" {file join $grandParentDir library} \\\n"
|
||||
" {file join $grandParentDir tcl[info tclversion] library} \\\n"
|
||||
" {file join $grandParentDir tcl[info patchlevel] library} \\\n"
|
||||
" {\n"
|
||||
"file join [file dirname $grandParentDir] tcl[info patchlevel] library}\n"
|
||||
@@ -661,9 +660,14 @@ NRInterpCmd(
|
||||
if (masterInterp == NULL) {
|
||||
return TCL_ERROR;
|
||||
}
|
||||
|
||||
return AliasCreate(interp, slaveInterp, masterInterp, objv[3],
|
||||
objv[5], objc - 6, objv + 6);
|
||||
if (TclGetString(objv[5])[0] == '\0') {
|
||||
if (objc == 6) {
|
||||
return AliasDelete(interp, slaveInterp, objv[3]);
|
||||
}
|
||||
} else {
|
||||
return AliasCreate(interp, slaveInterp, masterInterp, objv[3],
|
||||
objv[5], objc - 6, objv + 6);
|
||||
}
|
||||
}
|
||||
goto aliasArgs;
|
||||
}
|
||||
|
||||
+17
-24
@@ -393,9 +393,8 @@ LinkTraceProc(
|
||||
Tcl_ObjSetVar2(interp, linkPtr->varName, NULL, ObjValue(linkPtr),
|
||||
TCL_GLOBAL_ONLY);
|
||||
return (char *) "variable must have integer value";
|
||||
} else {
|
||||
LinkedVar(Tcl_WideInt) = linkPtr->lastValue.w;
|
||||
}
|
||||
LinkedVar(Tcl_WideInt) = linkPtr->lastValue.w;
|
||||
break;
|
||||
|
||||
case TCL_LINK_DOUBLE:
|
||||
@@ -408,9 +407,8 @@ LinkTraceProc(
|
||||
ObjValue(linkPtr), TCL_GLOBAL_ONLY);
|
||||
return (char *) "variable must have real value";
|
||||
#ifdef ACCEPT_NAN
|
||||
} else {
|
||||
linkPtr->lastValue.d = valueObj->internalRep.doubleValue;
|
||||
}
|
||||
linkPtr->lastValue.d = valueObj->internalRep.doubleValue;
|
||||
#endif
|
||||
}
|
||||
LinkedVar(double) = linkPtr->lastValue.d;
|
||||
@@ -427,7 +425,7 @@ LinkTraceProc(
|
||||
break;
|
||||
|
||||
case TCL_LINK_CHAR:
|
||||
if (Tcl_GetIntFromObj(NULL, valueObj, &valueInt) != TCL_OK
|
||||
if (Tcl_GetIntFromObj(interp, valueObj, &valueInt) != TCL_OK
|
||||
|| valueInt < SCHAR_MIN || valueInt > SCHAR_MAX) {
|
||||
Tcl_ObjSetVar2(interp, linkPtr->varName, NULL, ObjValue(linkPtr),
|
||||
TCL_GLOBAL_ONLY);
|
||||
@@ -438,7 +436,7 @@ LinkTraceProc(
|
||||
break;
|
||||
|
||||
case TCL_LINK_UCHAR:
|
||||
if (Tcl_GetIntFromObj(NULL, valueObj, &valueInt) != TCL_OK
|
||||
if (Tcl_GetIntFromObj(interp, valueObj, &valueInt) != TCL_OK
|
||||
|| valueInt < 0 || valueInt > UCHAR_MAX) {
|
||||
Tcl_ObjSetVar2(interp, linkPtr->varName, NULL, ObjValue(linkPtr),
|
||||
TCL_GLOBAL_ONLY);
|
||||
@@ -449,7 +447,7 @@ LinkTraceProc(
|
||||
break;
|
||||
|
||||
case TCL_LINK_SHORT:
|
||||
if (Tcl_GetIntFromObj(NULL, valueObj, &valueInt) != TCL_OK
|
||||
if (Tcl_GetIntFromObj(interp, valueObj, &valueInt) != TCL_OK
|
||||
|| valueInt < SHRT_MIN || valueInt > SHRT_MAX) {
|
||||
Tcl_ObjSetVar2(interp, linkPtr->varName, NULL, ObjValue(linkPtr),
|
||||
TCL_GLOBAL_ONLY);
|
||||
@@ -460,7 +458,7 @@ LinkTraceProc(
|
||||
break;
|
||||
|
||||
case TCL_LINK_USHORT:
|
||||
if (Tcl_GetIntFromObj(NULL, valueObj, &valueInt) != TCL_OK
|
||||
if (Tcl_GetIntFromObj(interp, valueObj, &valueInt) != TCL_OK
|
||||
|| valueInt < 0 || valueInt > USHRT_MAX) {
|
||||
Tcl_ObjSetVar2(interp, linkPtr->varName, NULL, ObjValue(linkPtr),
|
||||
TCL_GLOBAL_ONLY);
|
||||
@@ -471,38 +469,35 @@ LinkTraceProc(
|
||||
break;
|
||||
|
||||
case TCL_LINK_UINT:
|
||||
if (Tcl_GetWideIntFromObj(NULL, valueObj, &valueWide) != TCL_OK
|
||||
if (Tcl_GetWideIntFromObj(interp, valueObj, &valueWide) != TCL_OK
|
||||
|| valueWide < 0 || valueWide > UINT_MAX) {
|
||||
Tcl_ObjSetVar2(interp, linkPtr->varName, NULL, ObjValue(linkPtr),
|
||||
TCL_GLOBAL_ONLY);
|
||||
return (char *) "variable must have unsigned int value";
|
||||
} else {
|
||||
linkPtr->lastValue.ui = (unsigned int)valueWide;
|
||||
}
|
||||
linkPtr->lastValue.ui = (unsigned int)valueWide;
|
||||
LinkedVar(unsigned int) = linkPtr->lastValue.ui;
|
||||
break;
|
||||
|
||||
case TCL_LINK_LONG:
|
||||
if (Tcl_GetWideIntFromObj(NULL, valueObj, &valueWide) != TCL_OK
|
||||
if (Tcl_GetWideIntFromObj(interp, valueObj, &valueWide) != TCL_OK
|
||||
|| valueWide < LONG_MIN || valueWide > LONG_MAX) {
|
||||
Tcl_ObjSetVar2(interp, linkPtr->varName, NULL, ObjValue(linkPtr),
|
||||
TCL_GLOBAL_ONLY);
|
||||
return (char *) "variable must have long value";
|
||||
} else {
|
||||
linkPtr->lastValue.l = (long)valueWide;
|
||||
}
|
||||
linkPtr->lastValue.l = (long)valueWide;
|
||||
LinkedVar(long) = linkPtr->lastValue.l;
|
||||
break;
|
||||
|
||||
case TCL_LINK_ULONG:
|
||||
if (Tcl_GetWideIntFromObj(NULL, valueObj, &valueWide) != TCL_OK
|
||||
if (Tcl_GetWideIntFromObj(interp, valueObj, &valueWide) != TCL_OK
|
||||
|| valueWide < 0 || (Tcl_WideUInt) valueWide > ULONG_MAX) {
|
||||
Tcl_ObjSetVar2(interp, linkPtr->varName, NULL, ObjValue(linkPtr),
|
||||
TCL_GLOBAL_ONLY);
|
||||
return (char *) "variable must have unsigned long value";
|
||||
} else {
|
||||
linkPtr->lastValue.ul = (unsigned long)valueWide;
|
||||
}
|
||||
linkPtr->lastValue.ul = (unsigned long)valueWide;
|
||||
LinkedVar(unsigned long) = linkPtr->lastValue.ul;
|
||||
break;
|
||||
|
||||
@@ -510,25 +505,23 @@ LinkTraceProc(
|
||||
/*
|
||||
* FIXME: represent as a bignum.
|
||||
*/
|
||||
if (Tcl_GetWideIntFromObj(NULL, valueObj, &valueWide) != TCL_OK) {
|
||||
if (Tcl_GetWideIntFromObj(interp, valueObj, &valueWide) != TCL_OK) {
|
||||
Tcl_ObjSetVar2(interp, linkPtr->varName, NULL, ObjValue(linkPtr),
|
||||
TCL_GLOBAL_ONLY);
|
||||
return (char *) "variable must have unsigned wide int value";
|
||||
} else {
|
||||
linkPtr->lastValue.uw = (Tcl_WideUInt)valueWide;
|
||||
}
|
||||
linkPtr->lastValue.uw = (Tcl_WideUInt)valueWide;
|
||||
LinkedVar(Tcl_WideUInt) = linkPtr->lastValue.uw;
|
||||
break;
|
||||
|
||||
case TCL_LINK_FLOAT:
|
||||
if (Tcl_GetDoubleFromObj(NULL, valueObj, &valueDouble) != TCL_OK
|
||||
if (Tcl_GetDoubleFromObj(interp, valueObj, &valueDouble) != TCL_OK
|
||||
|| valueDouble < -FLT_MAX || valueDouble > FLT_MAX) {
|
||||
Tcl_ObjSetVar2(interp, linkPtr->varName, NULL, ObjValue(linkPtr),
|
||||
TCL_GLOBAL_ONLY);
|
||||
return (char *) "variable must have float value";
|
||||
} else {
|
||||
linkPtr->lastValue.f = (float)valueDouble;
|
||||
}
|
||||
linkPtr->lastValue.f = (float)valueDouble;
|
||||
LinkedVar(float) = linkPtr->lastValue.f;
|
||||
break;
|
||||
|
||||
@@ -584,7 +577,7 @@ ObjValue(
|
||||
return Tcl_NewDoubleObj(linkPtr->lastValue.d);
|
||||
case TCL_LINK_BOOLEAN:
|
||||
linkPtr->lastValue.i = LinkedVar(int);
|
||||
return Tcl_NewBooleanObj(linkPtr->lastValue.i);
|
||||
return Tcl_NewBooleanObj(linkPtr->lastValue.i != 0);
|
||||
case TCL_LINK_CHAR:
|
||||
linkPtr->lastValue.c = LinkedVar(char);
|
||||
return Tcl_NewIntObj(linkPtr->lastValue.c);
|
||||
|
||||
@@ -897,18 +897,18 @@ Tcl_ListObjReplace(
|
||||
}
|
||||
if (count < 0) {
|
||||
count = 0;
|
||||
} else if (first > INT_MAX - count /* Handle integer overflow */
|
||||
|| numElems < first+count) {
|
||||
} else if (numElems < first+count || first+count < 0) {
|
||||
/*
|
||||
* The 'first+count < 0' condition here guards agains integer
|
||||
* overflow in determining 'first+count'.
|
||||
*/
|
||||
|
||||
count = numElems - first;
|
||||
}
|
||||
|
||||
if (objc > LIST_MAX - (numElems - count)) {
|
||||
if (interp != NULL) {
|
||||
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
|
||||
"max length of a Tcl list (%d elements) exceeded",
|
||||
LIST_MAX));
|
||||
}
|
||||
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
|
||||
"max length of a Tcl list (%d elements) exceeded", LIST_MAX));
|
||||
return TCL_ERROR;
|
||||
}
|
||||
isShared = (listRepPtr->refCount > 1);
|
||||
@@ -1898,7 +1898,7 @@ SetListFromAny(
|
||||
while (--elemPtrs >= &listRepPtr->elements) {
|
||||
Tcl_DecrRefCount(*elemPtrs);
|
||||
}
|
||||
ckfree(listRepPtr);
|
||||
ckfree((char *) listRepPtr);
|
||||
return TCL_ERROR;
|
||||
}
|
||||
if (elemStart == limit) {
|
||||
|
||||
+20
-29
@@ -174,7 +174,7 @@ TclDeleteLiteralTable(
|
||||
Tcl_Obj *
|
||||
TclCreateLiteral(
|
||||
Interp *iPtr,
|
||||
const char *bytes, /* The start of the string. Note that this is
|
||||
char *bytes, /* The start of the string. Note that this is
|
||||
* not a NUL-terminated string. */
|
||||
int length, /* Number of bytes in the string. */
|
||||
unsigned hash, /* The string's hash. If -1, it will be
|
||||
@@ -214,7 +214,7 @@ TclCreateLiteral(
|
||||
if (globalPtrPtr) {
|
||||
*globalPtrPtr = globalPtr;
|
||||
}
|
||||
if ((flags & LITERAL_ON_HEAP)) {
|
||||
if (flags & LITERAL_ON_HEAP) {
|
||||
ckfree(bytes);
|
||||
}
|
||||
globalPtr->refCount++;
|
||||
@@ -222,40 +222,26 @@ TclCreateLiteral(
|
||||
}
|
||||
}
|
||||
if (!newPtr) {
|
||||
if ((flags & LITERAL_ON_HEAP)) {
|
||||
if (flags & LITERAL_ON_HEAP) {
|
||||
ckfree(bytes);
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/*
|
||||
* The literal is new to the interpreter.
|
||||
* The literal is new to the interpreter. Add it to the global literal
|
||||
* table.
|
||||
*/
|
||||
|
||||
TclNewObj(objPtr);
|
||||
if ((flags & LITERAL_ON_HEAP)) {
|
||||
objPtr->bytes = (char *) bytes;
|
||||
Tcl_IncrRefCount(objPtr);
|
||||
if (flags & LITERAL_ON_HEAP) {
|
||||
objPtr->bytes = bytes;
|
||||
objPtr->length = length;
|
||||
} else {
|
||||
TclInitStringRep(objPtr, bytes, length);
|
||||
}
|
||||
|
||||
/* Should the new literal be shared globally? */
|
||||
|
||||
if ((flags & LITERAL_UNSHARED)) {
|
||||
/*
|
||||
* No, do *not* add it the global literal table
|
||||
* Make clear, that no global value is returned
|
||||
*/
|
||||
if (globalPtrPtr != NULL) {
|
||||
*globalPtrPtr = NULL;
|
||||
}
|
||||
return objPtr;
|
||||
}
|
||||
|
||||
/*
|
||||
* Yes, add it to the global literal table.
|
||||
*/
|
||||
#ifdef TCL_COMPILE_DEBUG
|
||||
if (LookupLiteralEntry((Tcl_Interp *) iPtr, objPtr) != NULL) {
|
||||
Tcl_Panic("%s: literal \"%.*s\" found globally but shouldn't be",
|
||||
@@ -265,7 +251,6 @@ TclCreateLiteral(
|
||||
|
||||
globalPtr = ckalloc(sizeof(LiteralEntry));
|
||||
globalPtr->objPtr = objPtr;
|
||||
Tcl_IncrRefCount(objPtr);
|
||||
globalPtr->refCount = 1;
|
||||
globalPtr->nsPtr = nsPtr;
|
||||
globalPtr->nextPtr = globalTablePtr->buckets[globalHash];
|
||||
@@ -375,7 +360,7 @@ int
|
||||
TclRegisterLiteral(
|
||||
void *ePtr, /* Points to the CompileEnv in whose object
|
||||
* array an object is found or created. */
|
||||
register const char *bytes, /* Points to string for which to find or
|
||||
register char *bytes, /* Points to string for which to find or
|
||||
* create an object in CompileEnv's object
|
||||
* array. */
|
||||
int length, /* Number of bytes in the string. If < 0, the
|
||||
@@ -413,7 +398,7 @@ TclRegisterLiteral(
|
||||
if ((objPtr->length == length) && ((length == 0)
|
||||
|| ((objPtr->bytes[0] == bytes[0])
|
||||
&& (memcmp(objPtr->bytes, bytes, (unsigned) length) == 0)))) {
|
||||
if ((flags & LITERAL_ON_HEAP)) {
|
||||
if (flags & LITERAL_ON_HEAP) {
|
||||
ckfree(bytes);
|
||||
}
|
||||
objIndex = (localPtr - envPtr->literalArrayPtr);
|
||||
@@ -432,7 +417,7 @@ TclRegisterLiteral(
|
||||
* the namespace as the interp's global NS.
|
||||
*/
|
||||
|
||||
if ((flags & LITERAL_CMD_NAME)) {
|
||||
if (flags & LITERAL_CMD_NAME) {
|
||||
if ((length >= 2) && (bytes[0] == ':') && (bytes[1] == ':')) {
|
||||
nsPtr = iPtr->globalNsPtr;
|
||||
} else {
|
||||
@@ -446,13 +431,12 @@ TclRegisterLiteral(
|
||||
* Is it in the interpreter's global literal table? If not, create it.
|
||||
*/
|
||||
|
||||
globalPtr = NULL;
|
||||
objPtr = TclCreateLiteral(iPtr, bytes, length, hash, &new, nsPtr, flags,
|
||||
&globalPtr);
|
||||
objIndex = AddLocalLiteralEntry(envPtr, objPtr, localHash);
|
||||
|
||||
#ifdef TCL_COMPILE_DEBUG
|
||||
if (globalPtr != NULL && globalPtr->refCount < 1) {
|
||||
if (globalPtr->refCount < 1) {
|
||||
Tcl_Panic("%s: global literal \"%.*s\" had bad refCount %d",
|
||||
"TclRegisterLiteral", (length>60? 60 : length), bytes,
|
||||
globalPtr->refCount);
|
||||
@@ -1041,7 +1025,7 @@ TclInvalidateCmdLiteral(
|
||||
* invalidate a cmd literal. */
|
||||
{
|
||||
Interp *iPtr = (Interp *) interp;
|
||||
Tcl_Obj *literalObjPtr = TclCreateLiteral(iPtr, name,
|
||||
Tcl_Obj *literalObjPtr = TclCreateLiteral(iPtr, (char *) name,
|
||||
strlen(name), -1, NULL, nsPtr, 0, NULL);
|
||||
|
||||
if (literalObjPtr != NULL) {
|
||||
@@ -1168,6 +1152,13 @@ TclVerifyLocalLiteralTable(
|
||||
"TclVerifyLocalLiteralTable",
|
||||
(length>60? 60 : length), bytes, localPtr->refCount);
|
||||
}
|
||||
if (LookupLiteralEntry((Tcl_Interp *) envPtr->iPtr,
|
||||
localPtr->objPtr) == NULL) {
|
||||
bytes = TclGetStringFromObj(localPtr->objPtr, &length);
|
||||
Tcl_Panic("%s: local literal \"%.*s\" is not global",
|
||||
"TclVerifyLocalLiteralTable",
|
||||
(length>60? 60 : length), bytes);
|
||||
}
|
||||
if (localPtr->objPtr->bytes == NULL) {
|
||||
Tcl_Panic("%s: literal has NULL string rep",
|
||||
"TclVerifyLocalLiteralTable");
|
||||
|
||||
+1
-1
@@ -1015,7 +1015,7 @@ Tcl_StaticPackage(
|
||||
* TclGetLoadedPackages --
|
||||
*
|
||||
* This function returns information about all of the files that are
|
||||
* loaded (either in a particular interpreter, or for all interpreters).
|
||||
* loaded (either in a particular intepreter, or for all interpreters).
|
||||
*
|
||||
* Results:
|
||||
* The return value is a standard Tcl completion code. If successful, a
|
||||
|
||||
+6
-7
@@ -32,7 +32,7 @@
|
||||
*/
|
||||
|
||||
typedef struct ThreadSpecificData {
|
||||
size_t numNsCreated; /* Count of the number of namespaces created
|
||||
long numNsCreated; /* Count of the number of namespaces created
|
||||
* within the thread. This value is used as a
|
||||
* unique id for each namespace. Cannot be
|
||||
* per-interp because the nsId is used to
|
||||
@@ -59,7 +59,7 @@ typedef struct ResolvedNsName {
|
||||
* the name was resolved. NULL if the name is
|
||||
* fully qualified and thus the resolution
|
||||
* does not depend on the context. */
|
||||
size_t refCount; /* Reference count: 1 for each nsName object
|
||||
int refCount; /* Reference count: 1 for each nsName object
|
||||
* that has a pointer to this ResolvedNsName
|
||||
* structure as its internal rep. This
|
||||
* structure can be freed when refCount
|
||||
@@ -1326,7 +1326,8 @@ void
|
||||
TclNsDecrRefCount(
|
||||
Namespace *nsPtr)
|
||||
{
|
||||
if ((nsPtr->refCount-- <= 1) && (nsPtr->flags & NS_DEAD)) {
|
||||
nsPtr->refCount--;
|
||||
if ((nsPtr->refCount == 0) && (nsPtr->flags & NS_DEAD)) {
|
||||
NamespaceFree(nsPtr);
|
||||
}
|
||||
}
|
||||
@@ -2565,9 +2566,7 @@ Tcl_FindCommand(
|
||||
}
|
||||
|
||||
if (result == TCL_OK) {
|
||||
((Command *)cmd)->flags |= CMD_VIA_RESOLVER;
|
||||
return cmd;
|
||||
|
||||
} else if (result != TCL_CONTINUE) {
|
||||
return NULL;
|
||||
}
|
||||
@@ -2659,7 +2658,6 @@ Tcl_FindCommand(
|
||||
}
|
||||
|
||||
if (cmdPtr != NULL) {
|
||||
cmdPtr->flags &= ~CMD_VIA_RESOLVER;
|
||||
return (Tcl_Command) cmdPtr;
|
||||
}
|
||||
|
||||
@@ -4670,7 +4668,8 @@ FreeNsNameInternalRep(
|
||||
* references, free it up.
|
||||
*/
|
||||
|
||||
if (resNamePtr->refCount-- <= 1) {
|
||||
resNamePtr->refCount--;
|
||||
if (resNamePtr->refCount == 0) {
|
||||
/*
|
||||
* Decrement the reference count for the cached namespace. If the
|
||||
* namespace is dead, and there are no more references to it, free
|
||||
|
||||
@@ -179,7 +179,6 @@ StashCallChain(
|
||||
CallChain *callPtr)
|
||||
{
|
||||
callPtr->refCount++;
|
||||
TclGetString(objPtr);
|
||||
TclFreeIntRep(objPtr);
|
||||
objPtr->typePtr = &methodNameType;
|
||||
objPtr->internalRep.twoPtrValue.ptr1 = callPtr;
|
||||
|
||||
@@ -2217,7 +2217,7 @@ ClassSuperSet(
|
||||
"attempt to form circular dependency graph", -1));
|
||||
Tcl_SetErrorCode(interp, "TCL", "OO", "CIRCULARITY", NULL);
|
||||
failedAfterAlloc:
|
||||
ckfree(superclasses);
|
||||
ckfree((char *) superclasses);
|
||||
return TCL_ERROR;
|
||||
}
|
||||
}
|
||||
@@ -2234,7 +2234,7 @@ ClassSuperSet(
|
||||
FOREACH(superPtr, oPtr->classPtr->superclasses) {
|
||||
TclOORemoveFromSubclasses(oPtr->classPtr, superPtr);
|
||||
}
|
||||
ckfree(oPtr->classPtr->superclasses.list);
|
||||
ckfree((char *) oPtr->classPtr->superclasses.list);
|
||||
}
|
||||
oPtr->classPtr->superclasses.list = superclasses;
|
||||
oPtr->classPtr->superclasses.num = superc;
|
||||
@@ -2323,7 +2323,7 @@ ClassVarsSet(
|
||||
}
|
||||
|
||||
for (i=0 ; i<varc ; i++) {
|
||||
const char *varName = TclGetString(varv[i]);
|
||||
const char *varName = Tcl_GetString(varv[i]);
|
||||
|
||||
if (strstr(varName, "::") != NULL) {
|
||||
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
|
||||
@@ -2349,7 +2349,7 @@ ClassVarsSet(
|
||||
}
|
||||
if (i != varc) {
|
||||
if (varc == 0) {
|
||||
ckfree(oPtr->classPtr->variables.list);
|
||||
ckfree((char *) oPtr->classPtr->variables.list);
|
||||
} else if (i) {
|
||||
oPtr->classPtr->variables.list = (Tcl_Obj **)
|
||||
ckrealloc((char *) oPtr->classPtr->variables.list,
|
||||
@@ -2604,7 +2604,7 @@ ObjVarsSet(
|
||||
}
|
||||
|
||||
for (i=0 ; i<varc ; i++) {
|
||||
const char *varName = TclGetString(varv[i]);
|
||||
const char *varName = Tcl_GetString(varv[i]);
|
||||
|
||||
if (strstr(varName, "::") != NULL) {
|
||||
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
|
||||
@@ -2630,7 +2630,7 @@ ObjVarsSet(
|
||||
}
|
||||
if (i != varc) {
|
||||
if (varc == 0) {
|
||||
ckfree(oPtr->variables.list);
|
||||
ckfree((char *) oPtr->variables.list);
|
||||
} else if (i) {
|
||||
oPtr->variables.list = (Tcl_Obj **)
|
||||
ckrealloc((char *) oPtr->variables.list,
|
||||
|
||||
+1
-1
@@ -592,7 +592,7 @@ MODULE_SCOPE void TclOOSetupVariableResolver(Tcl_Namespace *nsPtr);
|
||||
#define AddRef(ptr) ((ptr)->refCount++)
|
||||
#define DelRef(ptr) do { \
|
||||
if ((ptr)->refCount-- <= 1) { \
|
||||
ckfree(ptr); \
|
||||
ckfree((char *) (ptr)); \
|
||||
} \
|
||||
} while(0)
|
||||
|
||||
|
||||
+11
-14
@@ -361,7 +361,7 @@ typedef struct ResolvedCmdName {
|
||||
* incremented; if so, the cmd was renamed,
|
||||
* deleted, hidden, or exposed, and so the
|
||||
* pointer is invalid. */
|
||||
size_t refCount; /* Reference count: 1 for each cmdName object
|
||||
int refCount; /* Reference count: 1 for each cmdName object
|
||||
* that has a pointer to this ResolvedCmdName
|
||||
* structure as its internal rep. This
|
||||
* structure can be freed when refCount
|
||||
@@ -1810,7 +1810,7 @@ Tcl_DbNewBooleanObj(
|
||||
TclDbNewObj(objPtr, file, line);
|
||||
objPtr->bytes = NULL;
|
||||
|
||||
objPtr->internalRep.longValue = (boolValue != 0);
|
||||
objPtr->internalRep.longValue = (boolValue? 1 : 0);
|
||||
objPtr->typePtr = &tclIntType;
|
||||
return objPtr;
|
||||
}
|
||||
@@ -2425,7 +2425,7 @@ Tcl_NewIntObj(
|
||||
{
|
||||
register Tcl_Obj *objPtr;
|
||||
|
||||
TclNewLongObj(objPtr, intValue);
|
||||
TclNewIntObj(objPtr, intValue);
|
||||
return objPtr;
|
||||
}
|
||||
#endif /* if TCL_MEM_DEBUG */
|
||||
@@ -3252,11 +3252,13 @@ UpdateStringOfBignum(
|
||||
if (status != MP_OKAY) {
|
||||
Tcl_Panic("radix size failure in UpdateStringOfBignum");
|
||||
}
|
||||
if (size < 2) {
|
||||
if (size == 3) {
|
||||
/*
|
||||
* mp_radix_size() returns < 2 when more than INT_MAX bytes would be
|
||||
* mp_radix_size() returns 3 when more than INT_MAX bytes would be
|
||||
* needed to hold the string rep (because mp_radix_size ignores
|
||||
* integer overflow issues).
|
||||
* integer overflow issues). When we know the string rep will be more
|
||||
* than 3, we can conclude the string rep would overflow our string
|
||||
* length limits.
|
||||
*
|
||||
* Note that so long as we enforce our bignums to the size that fits
|
||||
* in a packed bignum, this branch will never be taken.
|
||||
@@ -4262,13 +4264,8 @@ TclSetCmdNameObj(
|
||||
Command *cmdPtr) /* Points to Command structure that the
|
||||
* CmdName object should refer to. */
|
||||
{
|
||||
register ResolvedCmdName *resPtr;
|
||||
|
||||
if (objPtr->typePtr == &tclCmdNameType) {
|
||||
resPtr = objPtr->internalRep.twoPtrValue.ptr1;
|
||||
if (resPtr != NULL && resPtr->cmdPtr == cmdPtr) {
|
||||
return;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
SetCmdNameObj(interp, objPtr, cmdPtr, NULL);
|
||||
@@ -4307,7 +4304,7 @@ FreeCmdNameInternalRep(
|
||||
* there are no more uses, free the ResolvedCmdName structure.
|
||||
*/
|
||||
|
||||
if (resPtr->refCount-- <= 1) {
|
||||
if (resPtr->refCount-- == 1) {
|
||||
/*
|
||||
* Now free the cached command, unless it is still in its hash
|
||||
* table or if there are other references to it from other cmdName
|
||||
@@ -4419,7 +4416,7 @@ SetCmdNameFromAny(
|
||||
|
||||
Command *oldCmdPtr = resPtr->cmdPtr;
|
||||
|
||||
if (oldCmdPtr->refCount-- <= 1) {
|
||||
if (--oldCmdPtr->refCount == 0) {
|
||||
TclCleanupCommandMacro(oldCmdPtr);
|
||||
}
|
||||
} else {
|
||||
|
||||
+1
-1
@@ -60,7 +60,7 @@ static TclFile FileForRedirect(Tcl_Interp *interp, const char *spec,
|
||||
|
||||
static TclFile
|
||||
FileForRedirect(
|
||||
Tcl_Interp *interp, /* Interpreter to use for error reporting. */
|
||||
Tcl_Interp *interp, /* Intepreter to use for error reporting. */
|
||||
const char *spec, /* Points to character just after redirection
|
||||
* character. */
|
||||
int atOK, /* Non-zero means that '@' notation can be
|
||||
|
||||
@@ -22,7 +22,7 @@
|
||||
|
||||
typedef struct {
|
||||
ClientData clientData; /* Address of preserved block. */
|
||||
size_t refCount; /* Number of Tcl_Preserve calls in effect for
|
||||
int refCount; /* Number of Tcl_Preserve calls in effect for
|
||||
* block. */
|
||||
int mustFree; /* Non-zero means Tcl_EventuallyFree was
|
||||
* called while a Tcl_Preserve call was in
|
||||
@@ -63,7 +63,7 @@ typedef struct HandleStruct {
|
||||
* ensure that the contents of the handle are
|
||||
* not changed by anyone else. */
|
||||
#endif
|
||||
size_t refCount; /* Number of TclHandlePreserve() calls in
|
||||
int refCount; /* Number of TclHandlePreserve() calls in
|
||||
* effect on this handle. */
|
||||
} HandleStruct;
|
||||
|
||||
@@ -195,7 +195,7 @@ Tcl_Release(
|
||||
continue;
|
||||
}
|
||||
|
||||
if (refPtr->refCount-- > 1) {
|
||||
if (--refPtr->refCount != 0) {
|
||||
Tcl_MutexUnlock(&preserveMutex);
|
||||
return;
|
||||
}
|
||||
@@ -459,7 +459,7 @@ TclHandleRelease(
|
||||
handlePtr, handlePtr->ptr2, handlePtr->ptr);
|
||||
}
|
||||
#endif
|
||||
if ((handlePtr->refCount-- <= 1) && (handlePtr->ptr == NULL)) {
|
||||
if ((--handlePtr->refCount == 0) && (handlePtr->ptr == NULL)) {
|
||||
ckfree(handlePtr);
|
||||
}
|
||||
}
|
||||
|
||||
+3
-10
@@ -502,16 +502,9 @@ Tcl_RegExpMatchObj(
|
||||
{
|
||||
Tcl_RegExp re;
|
||||
|
||||
/*
|
||||
* For performance reasons, first try compiling the RE without support for
|
||||
* subexpressions. On failure, try again without TCL_REG_NOSUB in case the
|
||||
* RE has backreferences in it. Closely related to [Bug 1366683]. If this
|
||||
* still fails, an error message will be left in the interpreter.
|
||||
*/
|
||||
|
||||
if (!(re = Tcl_GetRegExpFromObj(interp, patternObj,
|
||||
TCL_REG_ADVANCED | TCL_REG_NOSUB))
|
||||
&& !(re = Tcl_GetRegExpFromObj(interp, patternObj, TCL_REG_ADVANCED))) {
|
||||
re = Tcl_GetRegExpFromObj(interp, patternObj,
|
||||
TCL_REG_ADVANCED | TCL_REG_NOSUB);
|
||||
if (re == NULL) {
|
||||
return -1;
|
||||
}
|
||||
return Tcl_RegExpExecObj(interp, re, textObj, 0 /* offset */,
|
||||
|
||||
+1
-1
@@ -37,7 +37,7 @@ typedef struct TclRegexp {
|
||||
* of subexpressions. */
|
||||
rm_detail_t details; /* Detailed information on match (currently
|
||||
* used only for REG_EXPECT). */
|
||||
unsigned int refCount; /* Count of number of references to this
|
||||
int refCount; /* Count of number of references to this
|
||||
* compiled regexp. */
|
||||
} TclRegexp;
|
||||
|
||||
|
||||
@@ -396,9 +396,6 @@ static Tcl_WideUInt Nokia770Twiddle(Tcl_WideUInt w);
|
||||
* - TCL_PARSE_SCAN_PREFIXES: ignore the prefixes 0b and 0o that are
|
||||
* not part of the [scan] command's vocabulary. Use only in
|
||||
* combination with TCL_PARSE_INTEGER_ONLY.
|
||||
* - TCL_PARSE_BINARY_ONLY: parse only in the binary format, whether
|
||||
* or not a prefix is present that would lead to binary parsing.
|
||||
* Use only in combination with TCL_PARSE_INTEGER_ONLY.
|
||||
* - TCL_PARSE_OCTAL_ONLY: parse only in the octal format, whether
|
||||
* or not a prefix is present that would lead to octal parsing.
|
||||
* Use only in combination with TCL_PARSE_INTEGER_ONLY.
|
||||
@@ -630,9 +627,6 @@ TclParseNumber(
|
||||
acceptPoint = p;
|
||||
acceptLen = len;
|
||||
if (c == 'x' || c == 'X') {
|
||||
if (flags & (TCL_PARSE_OCTAL_ONLY|TCL_PARSE_BINARY_ONLY)) {
|
||||
goto endgame;
|
||||
}
|
||||
state = ZERO_X;
|
||||
break;
|
||||
}
|
||||
@@ -643,9 +637,6 @@ TclParseNumber(
|
||||
goto zeroo;
|
||||
}
|
||||
if (c == 'b' || c == 'B') {
|
||||
if (flags & TCL_PARSE_OCTAL_ONLY) {
|
||||
goto endgame;
|
||||
}
|
||||
state = ZERO_B;
|
||||
break;
|
||||
}
|
||||
|
||||
+2
-656
@@ -408,15 +408,6 @@ Tcl_GetCharLength(
|
||||
String *stringPtr;
|
||||
int numChars;
|
||||
|
||||
/*
|
||||
* Quick, no-shimmer return for short string reps.
|
||||
*/
|
||||
|
||||
if ((objPtr->bytes) && (objPtr->length < 2)) {
|
||||
/* 0 bytes -> 0 chars; 1 byte -> 1 char */
|
||||
return objPtr->length;
|
||||
}
|
||||
|
||||
/*
|
||||
* Optimize the case where we're really dealing with a bytearray object
|
||||
* without string representation; we don't need to convert to a string to
|
||||
@@ -1182,8 +1173,6 @@ Tcl_AppendUnicodeToObj(
|
||||
* Side effects:
|
||||
* The string rep of appendObjPtr is appended to the string
|
||||
* representation of objPtr.
|
||||
* IMPORTANT: This routine does not and MUST NOT shimmer appendObjPtr.
|
||||
* Callers are counting on that.
|
||||
*
|
||||
*----------------------------------------------------------------------
|
||||
*/
|
||||
@@ -1865,14 +1854,6 @@ Tcl_AppendFormatToObj(
|
||||
useWide = 1;
|
||||
#endif
|
||||
}
|
||||
} else if ((ch == 'I') && (format[1] == '6') && (format[2] == '4')) {
|
||||
format += (step + 2);
|
||||
step = Tcl_UtfToUniChar(format, &ch);
|
||||
useBig = 1;
|
||||
} else if (ch == 'L') {
|
||||
format += step;
|
||||
step = Tcl_UtfToUniChar(format, &ch);
|
||||
useBig = 1;
|
||||
}
|
||||
|
||||
format += step;
|
||||
@@ -2480,10 +2461,6 @@ AppendPrintfToObjVA(
|
||||
Tcl_ListObjAppendElement(NULL, list, Tcl_NewLongObj(
|
||||
va_arg(argList, long)));
|
||||
break;
|
||||
case 2:
|
||||
Tcl_ListObjAppendElement(NULL, list, Tcl_NewWideIntObj(
|
||||
va_arg(argList, Tcl_WideInt)));
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case 'e':
|
||||
@@ -2512,20 +2489,9 @@ AppendPrintfToObjVA(
|
||||
gotPrecision = 1;
|
||||
p++;
|
||||
break;
|
||||
/* TODO: support for bignum arguments */
|
||||
/* TODO: support for wide (and bignum?) arguments */
|
||||
case 'l':
|
||||
++size;
|
||||
p++;
|
||||
break;
|
||||
case 'L':
|
||||
size = 2;
|
||||
p++;
|
||||
break;
|
||||
case 'I':
|
||||
if (p[1]=='6' && p[2]=='4') {
|
||||
p += 2;
|
||||
size = 2;
|
||||
}
|
||||
size = 1;
|
||||
p++;
|
||||
break;
|
||||
case 'h':
|
||||
@@ -2632,616 +2598,6 @@ TclGetStringStorage(
|
||||
*sizePtr = stringPtr->allocated;
|
||||
return objPtr->bytes;
|
||||
}
|
||||
|
||||
/*
|
||||
*---------------------------------------------------------------------------
|
||||
*
|
||||
* TclStringRepeat --
|
||||
*
|
||||
* Performs the [string repeat] function.
|
||||
*
|
||||
* Results:
|
||||
* A standard Tcl result.
|
||||
*
|
||||
* Side effects:
|
||||
* Writes to *objPtrPtr the address of Tcl_Obj that is concatenation
|
||||
* of count copies of the value in objPtr.
|
||||
*
|
||||
*---------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
int
|
||||
TclStringRepeat(
|
||||
Tcl_Interp *interp,
|
||||
Tcl_Obj *objPtr,
|
||||
int count,
|
||||
Tcl_Obj **objPtrPtr)
|
||||
{
|
||||
Tcl_Obj *objResultPtr;
|
||||
int length = 0, unichar = 0, done = 1;
|
||||
int binary = TclIsPureByteArray(objPtr);
|
||||
|
||||
/* assert (count >= 2) */
|
||||
|
||||
/*
|
||||
* Analyze to determine what representation result should be.
|
||||
* GOALS: Avoid shimmering & string rep generation.
|
||||
* Produce pure bytearray when possible.
|
||||
* Error on overflow.
|
||||
*/
|
||||
|
||||
if (!binary) {
|
||||
if (objPtr->typePtr == &tclStringType) {
|
||||
String *stringPtr = GET_STRING(objPtr);
|
||||
if (stringPtr->hasUnicode) {
|
||||
unichar = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (binary) {
|
||||
/* Result will be pure byte array. Pre-size it */
|
||||
Tcl_GetByteArrayFromObj(objPtr, &length);
|
||||
} else if (unichar) {
|
||||
/* Result will be pure Tcl_UniChar array. Pre-size it. */
|
||||
Tcl_GetUnicodeFromObj(objPtr, &length);
|
||||
} else {
|
||||
/* Result will be concat of string reps. Pre-size it. */
|
||||
Tcl_GetStringFromObj(objPtr, &length);
|
||||
}
|
||||
|
||||
if (length == 0) {
|
||||
/* Any repeats of empty is empty. */
|
||||
*objPtrPtr = objPtr;
|
||||
return TCL_OK;
|
||||
}
|
||||
|
||||
if (count > INT_MAX/length) {
|
||||
if (interp) {
|
||||
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
|
||||
"max size for a Tcl value (%d bytes) exceeded", INT_MAX));
|
||||
Tcl_SetErrorCode(interp, "TCL", "MEMORY", NULL);
|
||||
}
|
||||
return TCL_ERROR;
|
||||
}
|
||||
|
||||
if (binary) {
|
||||
/* Efficiently produce a pure byte array result */
|
||||
objResultPtr = Tcl_IsShared(objPtr) ? Tcl_DuplicateObj(objPtr)
|
||||
: objPtr;
|
||||
|
||||
Tcl_SetByteArrayLength(objResultPtr, count*length); /* PANIC? */
|
||||
Tcl_SetByteArrayLength(objResultPtr, length);
|
||||
while (count - done > done) {
|
||||
Tcl_AppendObjToObj(objResultPtr, objResultPtr);
|
||||
done *= 2;
|
||||
}
|
||||
TclAppendBytesToByteArray(objResultPtr,
|
||||
Tcl_GetByteArrayFromObj(objResultPtr, NULL),
|
||||
(count - done) * length);
|
||||
} else if (unichar) {
|
||||
/* Efficiently produce a pure Tcl_UniChar array result */
|
||||
if (Tcl_IsShared(objPtr)) {
|
||||
objResultPtr = Tcl_NewUnicodeObj(Tcl_GetUnicode(objPtr), length);
|
||||
} else {
|
||||
TclInvalidateStringRep(objPtr);
|
||||
objResultPtr = objPtr;
|
||||
}
|
||||
|
||||
if (0 == Tcl_AttemptSetObjLength(objResultPtr, count*length)) {
|
||||
if (interp) {
|
||||
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
|
||||
"string size overflow: unable to alloc %"
|
||||
TCL_LL_MODIFIER "u bytes",
|
||||
(Tcl_WideUInt)STRING_SIZE(count*length)));
|
||||
Tcl_SetErrorCode(interp, "TCL", "MEMORY", NULL);
|
||||
}
|
||||
return TCL_ERROR;
|
||||
}
|
||||
Tcl_SetObjLength(objResultPtr, length);
|
||||
while (count - done > done) {
|
||||
Tcl_AppendObjToObj(objResultPtr, objResultPtr);
|
||||
done *= 2;
|
||||
}
|
||||
Tcl_AppendUnicodeToObj(objResultPtr, Tcl_GetUnicode(objResultPtr),
|
||||
(count - done) * length);
|
||||
} else {
|
||||
/* Efficiently concatenate string reps */
|
||||
if (Tcl_IsShared(objPtr)) {
|
||||
objResultPtr = Tcl_NewStringObj(Tcl_GetString(objPtr), length);
|
||||
} else {
|
||||
TclFreeIntRep(objPtr);
|
||||
objResultPtr = objPtr;
|
||||
}
|
||||
if (0 == Tcl_AttemptSetObjLength(objResultPtr, count*length)) {
|
||||
if (interp) {
|
||||
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
|
||||
"string size overflow: unable to alloc %u bytes",
|
||||
count*length));
|
||||
Tcl_SetErrorCode(interp, "TCL", "MEMORY", NULL);
|
||||
}
|
||||
return TCL_ERROR;
|
||||
}
|
||||
Tcl_SetObjLength(objResultPtr, length);
|
||||
while (count - done > done) {
|
||||
Tcl_AppendObjToObj(objResultPtr, objResultPtr);
|
||||
done *= 2;
|
||||
}
|
||||
Tcl_AppendToObj(objResultPtr, Tcl_GetString(objResultPtr),
|
||||
(count - done) * length);
|
||||
}
|
||||
*objPtrPtr = objResultPtr;
|
||||
return TCL_OK;
|
||||
}
|
||||
|
||||
/*
|
||||
*---------------------------------------------------------------------------
|
||||
*
|
||||
* TclStringCatObjv --
|
||||
*
|
||||
* Performs the [string cat] function.
|
||||
*
|
||||
* Results:
|
||||
* A standard Tcl result.
|
||||
*
|
||||
* Side effects:
|
||||
* Writes to *objPtrPtr the address of Tcl_Obj that is concatenation
|
||||
* of all objc values in objv.
|
||||
*
|
||||
*---------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
int
|
||||
TclStringCatObjv(
|
||||
Tcl_Interp *interp,
|
||||
int inPlace,
|
||||
int objc,
|
||||
Tcl_Obj * const objv[],
|
||||
Tcl_Obj **objPtrPtr)
|
||||
{
|
||||
Tcl_Obj *objPtr, *objResultPtr, * const *ov;
|
||||
int oc, length = 0, binary = 1, first = 0;
|
||||
int allowUniChar = 1, requestUniChar = 0;
|
||||
|
||||
/* assert (objc >= 2) */
|
||||
|
||||
/*
|
||||
* Analyze to determine what representation result should be.
|
||||
* GOALS: Avoid shimmering & string rep generation.
|
||||
* Produce pure bytearray when possible.
|
||||
* Error on overflow.
|
||||
*/
|
||||
|
||||
ov = objv, oc = objc;
|
||||
while (oc-- && (binary || allowUniChar)) {
|
||||
objPtr = *ov++;
|
||||
|
||||
if (objPtr->bytes) {
|
||||
/* Value has a string rep. */
|
||||
if (objPtr->length) {
|
||||
/*
|
||||
* Non-empty string rep. Not a pure bytearray, so we
|
||||
* won't create a pure bytearray
|
||||
*/
|
||||
binary = 0;
|
||||
if ((objPtr->typePtr) && (objPtr->typePtr != &tclStringType)) {
|
||||
/* Prevent shimmer of non-string types. */
|
||||
allowUniChar = 0;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
/* assert (objPtr->typePtr != NULL) -- stork! */
|
||||
if (TclIsPureByteArray(objPtr)) {
|
||||
allowUniChar = 0;
|
||||
} else {
|
||||
binary = 0;
|
||||
if (objPtr->typePtr == &tclStringType) {
|
||||
/* Have a pure Unicode value; ask to preserve it */
|
||||
requestUniChar = 1;
|
||||
} else {
|
||||
/* Have another type; prevent shimmer */
|
||||
allowUniChar = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (binary) {
|
||||
/* Result will be pure byte array. Pre-size it */
|
||||
ov = objv; oc = objc;
|
||||
while (oc-- && (length >= 0)) {
|
||||
objPtr = *ov++;
|
||||
|
||||
if (objPtr->bytes == NULL) {
|
||||
int numBytes;
|
||||
|
||||
Tcl_GetByteArrayFromObj(objPtr, &numBytes); /* PANIC? */
|
||||
if (length == 0) {
|
||||
first = objc - oc - 1;
|
||||
}
|
||||
length += numBytes;
|
||||
}
|
||||
}
|
||||
} else if (allowUniChar && requestUniChar) {
|
||||
/* Result will be pure Tcl_UniChar array. Pre-size it. */
|
||||
ov = objv; oc = objc;
|
||||
while (oc-- && (length >= 0)) {
|
||||
objPtr = *ov++;
|
||||
|
||||
if ((objPtr->bytes == NULL) || (objPtr->length)) {
|
||||
int numChars;
|
||||
|
||||
Tcl_GetUnicodeFromObj(objPtr, &numChars); /* PANIC? */
|
||||
if (length == 0) {
|
||||
first = objc - oc - 1;
|
||||
}
|
||||
length += numChars;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
/* Result will be concat of string reps. Pre-size it. */
|
||||
ov = objv; oc = objc;
|
||||
while (oc-- && (length >= 0)) {
|
||||
int numBytes;
|
||||
|
||||
objPtr = *ov++;
|
||||
|
||||
Tcl_GetStringFromObj(objPtr, &numBytes); /* PANIC? */
|
||||
if ((length == 0) && numBytes) {
|
||||
first = objc - oc - 1;
|
||||
}
|
||||
length += numBytes;
|
||||
}
|
||||
}
|
||||
|
||||
if (length < 0) {
|
||||
if (interp) {
|
||||
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
|
||||
"max size for a Tcl value (%d bytes) exceeded", INT_MAX));
|
||||
Tcl_SetErrorCode(interp, "TCL", "MEMORY", NULL);
|
||||
}
|
||||
return TCL_ERROR;
|
||||
}
|
||||
|
||||
if (length == 0) {
|
||||
/* Total length of zero means every value has length zero */
|
||||
*objPtrPtr = objv[0];
|
||||
return TCL_OK;
|
||||
}
|
||||
|
||||
objv += first; objc -= first;
|
||||
|
||||
if (binary) {
|
||||
/* Efficiently produce a pure byte array result */
|
||||
unsigned char *dst;
|
||||
|
||||
/*
|
||||
* Broken interface! Byte array value routines offer no way
|
||||
* to handle failure to allocate enough space. Following
|
||||
* stanza may panic.
|
||||
*/
|
||||
if (inPlace && !Tcl_IsShared(*objv)) {
|
||||
int start;
|
||||
|
||||
objResultPtr = *objv++; objc--;
|
||||
Tcl_GetByteArrayFromObj(objResultPtr, &start);
|
||||
dst = Tcl_SetByteArrayLength(objResultPtr, length) + start;
|
||||
} else {
|
||||
objResultPtr = Tcl_NewByteArrayObj(NULL, length);
|
||||
dst = Tcl_SetByteArrayLength(objResultPtr, length);
|
||||
}
|
||||
while (objc--) {
|
||||
Tcl_Obj *objPtr = *objv++;
|
||||
|
||||
if (objPtr->bytes == NULL) {
|
||||
int more;
|
||||
unsigned char *src = Tcl_GetByteArrayFromObj(objPtr, &more);
|
||||
memcpy(dst, src, (size_t) more);
|
||||
dst += more;
|
||||
}
|
||||
}
|
||||
} else if (allowUniChar && requestUniChar) {
|
||||
/* Efficiently produce a pure Tcl_UniChar array result */
|
||||
Tcl_UniChar *dst;
|
||||
|
||||
if (inPlace && !Tcl_IsShared(*objv)) {
|
||||
int start;
|
||||
|
||||
objResultPtr = *objv++; objc--;
|
||||
|
||||
/* Ugly interface! Force resize of the unicode array. */
|
||||
Tcl_GetUnicodeFromObj(objResultPtr, &start);
|
||||
Tcl_InvalidateStringRep(objResultPtr);
|
||||
if (0 == Tcl_AttemptSetObjLength(objResultPtr, length)) {
|
||||
if (interp) {
|
||||
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
|
||||
"concatenation failed: unable to alloc %"
|
||||
TCL_LL_MODIFIER "u bytes",
|
||||
(Tcl_WideUInt)STRING_SIZE(length)));
|
||||
Tcl_SetErrorCode(interp, "TCL", "MEMORY", NULL);
|
||||
}
|
||||
return TCL_ERROR;
|
||||
}
|
||||
dst = Tcl_GetUnicode(objResultPtr) + start;
|
||||
} else {
|
||||
Tcl_UniChar ch = 0;
|
||||
|
||||
/* Ugly interface! No scheme to init array size. */
|
||||
objResultPtr = Tcl_NewUnicodeObj(&ch, 0); /* PANIC? */
|
||||
if (0 == Tcl_AttemptSetObjLength(objResultPtr, length)) {
|
||||
if (interp) {
|
||||
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
|
||||
"concatenation failed: unable to alloc %"
|
||||
TCL_LL_MODIFIER "u bytes",
|
||||
(Tcl_WideUInt)STRING_SIZE(length)));
|
||||
Tcl_SetErrorCode(interp, "TCL", "MEMORY", NULL);
|
||||
}
|
||||
return TCL_ERROR;
|
||||
}
|
||||
dst = Tcl_GetUnicode(objResultPtr);
|
||||
}
|
||||
while (objc--) {
|
||||
Tcl_Obj *objPtr = *objv++;
|
||||
|
||||
if ((objPtr->bytes == NULL) || (objPtr->length)) {
|
||||
int more;
|
||||
Tcl_UniChar *src = Tcl_GetUnicodeFromObj(objPtr, &more);
|
||||
memcpy(dst, src, more * sizeof(Tcl_UniChar));
|
||||
dst += more;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
/* Efficiently concatenate string reps */
|
||||
char *dst;
|
||||
|
||||
if (inPlace && !Tcl_IsShared(*objv)) {
|
||||
int start;
|
||||
|
||||
objResultPtr = *objv++; objc--;
|
||||
|
||||
Tcl_GetStringFromObj(objResultPtr, &start);
|
||||
if (0 == Tcl_AttemptSetObjLength(objResultPtr, length)) {
|
||||
if (interp) {
|
||||
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
|
||||
"concatenation failed: unable to alloc %u bytes",
|
||||
length));
|
||||
Tcl_SetErrorCode(interp, "TCL", "MEMORY", NULL);
|
||||
}
|
||||
return TCL_ERROR;
|
||||
}
|
||||
dst = Tcl_GetString(objResultPtr) + start;
|
||||
if (length > start) {
|
||||
TclFreeIntRep(objResultPtr);
|
||||
}
|
||||
} else {
|
||||
objResultPtr = Tcl_NewObj(); /* PANIC? */
|
||||
if (0 == Tcl_AttemptSetObjLength(objResultPtr, length)) {
|
||||
if (interp) {
|
||||
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
|
||||
"concatenation failed: unable to alloc %u bytes",
|
||||
length));
|
||||
Tcl_SetErrorCode(interp, "TCL", "MEMORY", NULL);
|
||||
}
|
||||
return TCL_ERROR;
|
||||
}
|
||||
dst = Tcl_GetString(objResultPtr);
|
||||
}
|
||||
while (objc--) {
|
||||
Tcl_Obj *objPtr = *objv++;
|
||||
|
||||
if ((objPtr->bytes == NULL) || (objPtr->length)) {
|
||||
int more;
|
||||
char *src = Tcl_GetStringFromObj(objPtr, &more);
|
||||
memcpy(dst, src, (size_t) more);
|
||||
dst += more;
|
||||
}
|
||||
}
|
||||
}
|
||||
*objPtrPtr = objResultPtr;
|
||||
return TCL_OK;
|
||||
}
|
||||
|
||||
/*
|
||||
*---------------------------------------------------------------------------
|
||||
*
|
||||
* TclStringFind --
|
||||
*
|
||||
* Implements the [string first] operation.
|
||||
*
|
||||
* Results:
|
||||
* If needle is found as a substring of haystack, the index of the
|
||||
* first instance of such a find is returned. If needle is not present
|
||||
* as a substring of haystack, -1 is returned.
|
||||
*
|
||||
* Side effects:
|
||||
* needle and haystack may have their Tcl_ObjType changed.
|
||||
*
|
||||
*---------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
int
|
||||
TclStringFind(
|
||||
Tcl_Obj *needle,
|
||||
Tcl_Obj *haystack,
|
||||
int start)
|
||||
{
|
||||
int lh, ln = Tcl_GetCharLength(needle);
|
||||
|
||||
if (ln == 0) {
|
||||
/*
|
||||
* We don't find empty substrings. Bizarre!
|
||||
*
|
||||
* TODO: When we one day make this a true substring
|
||||
* finder, change this to "return 0"
|
||||
*/
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (TclIsPureByteArray(needle) && TclIsPureByteArray(haystack)) {
|
||||
unsigned char *end, *try, *bh;
|
||||
unsigned char *bn = Tcl_GetByteArrayFromObj(needle, &ln);
|
||||
|
||||
bh = Tcl_GetByteArrayFromObj(haystack, &lh);
|
||||
end = bh + lh;
|
||||
|
||||
try = bh + start;
|
||||
while (try + ln <= end) {
|
||||
try = memchr(try, bn[0], end - try);
|
||||
|
||||
if (try == NULL) {
|
||||
return -1;
|
||||
}
|
||||
if (0 == memcmp(try+1, bn+1, ln-1)) {
|
||||
return (try - bh);
|
||||
}
|
||||
try++;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
lh = Tcl_GetCharLength(haystack);
|
||||
if (haystack->bytes && (lh == haystack->length)) {
|
||||
/* haystack is all single-byte chars */
|
||||
|
||||
if (needle->bytes && (ln == needle->length)) {
|
||||
/* needle is also all single-byte chars */
|
||||
char *found = strstr(haystack->bytes + start, needle->bytes);
|
||||
|
||||
if (found) {
|
||||
return (found - haystack->bytes);
|
||||
} else {
|
||||
return -1;
|
||||
}
|
||||
} else {
|
||||
/*
|
||||
* Cannot find substring with a multi-byte char inside
|
||||
* a string with no multi-byte chars.
|
||||
*/
|
||||
return -1;
|
||||
}
|
||||
} else {
|
||||
Tcl_UniChar *try, *end, *uh;
|
||||
Tcl_UniChar *un = Tcl_GetUnicodeFromObj(needle, &ln);
|
||||
|
||||
uh = Tcl_GetUnicodeFromObj(haystack, &lh);
|
||||
end = uh + lh;
|
||||
|
||||
try = uh + start;
|
||||
while (try + ln <= end) {
|
||||
if ((*try == *un)
|
||||
&& (0 == memcmp(try+1, un+1, (ln-1)*sizeof(Tcl_UniChar)))) {
|
||||
return (try - uh);
|
||||
}
|
||||
try++;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
*---------------------------------------------------------------------------
|
||||
*
|
||||
* TclStringLast --
|
||||
*
|
||||
* Implements the [string last] operation.
|
||||
*
|
||||
* Results:
|
||||
* If needle is found as a substring of haystack, the index of the
|
||||
* last instance of such a find is returned. If needle is not present
|
||||
* as a substring of haystack, -1 is returned.
|
||||
*
|
||||
* Side effects:
|
||||
* needle and haystack may have their Tcl_ObjType changed.
|
||||
*
|
||||
*---------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
int
|
||||
TclStringLast(
|
||||
Tcl_Obj *needle,
|
||||
Tcl_Obj *haystack,
|
||||
int last)
|
||||
{
|
||||
int lh, ln = Tcl_GetCharLength(needle);
|
||||
|
||||
if (ln == 0) {
|
||||
/*
|
||||
* We don't find empty substrings. Bizarre!
|
||||
*
|
||||
* TODO: When we one day make this a true substring
|
||||
* finder, change this to "return 0"
|
||||
*/
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (ln > last + 1) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (TclIsPureByteArray(needle) && TclIsPureByteArray(haystack)) {
|
||||
unsigned char *try, *bh;
|
||||
unsigned char *bn = Tcl_GetByteArrayFromObj(needle, &ln);
|
||||
|
||||
bh = Tcl_GetByteArrayFromObj(haystack, &lh);
|
||||
|
||||
if (last + 1 > lh) {
|
||||
last = lh - 1;
|
||||
}
|
||||
try = bh + last + 1 - ln;
|
||||
while (try >= bh) {
|
||||
if ((*try == bn[0])
|
||||
&& (0 == memcmp(try+1, bn+1, ln-1))) {
|
||||
return (try - bh);
|
||||
}
|
||||
try--;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
lh = Tcl_GetCharLength(haystack);
|
||||
if (last + 1 > lh) {
|
||||
last = lh - 1;
|
||||
}
|
||||
if (haystack->bytes && (lh == haystack->length)) {
|
||||
/* haystack is all single-byte chars */
|
||||
|
||||
if (needle->bytes && (ln == needle->length)) {
|
||||
/* needle is also all single-byte chars */
|
||||
|
||||
char *try = haystack->bytes + last + 1 - ln;
|
||||
while (try >= haystack->bytes) {
|
||||
if ((*try == needle->bytes[0])
|
||||
&& (0 == memcmp(try+1, needle->bytes + 1, ln - 1))) {
|
||||
return (try - haystack->bytes);
|
||||
}
|
||||
try--;
|
||||
}
|
||||
return -1;
|
||||
} else {
|
||||
/*
|
||||
* Cannot find substring with a multi-byte char inside
|
||||
* a string with no multi-byte chars.
|
||||
*/
|
||||
return -1;
|
||||
}
|
||||
} else {
|
||||
Tcl_UniChar *try, *uh;
|
||||
Tcl_UniChar *un = Tcl_GetUnicodeFromObj(needle, &ln);
|
||||
|
||||
uh = Tcl_GetUnicodeFromObj(haystack, &lh);
|
||||
|
||||
try = uh + last + 1 - ln;
|
||||
while (try >= uh) {
|
||||
if ((*try == un[0])
|
||||
&& (0 == memcmp(try+1, un+1, (ln-1)*sizeof(Tcl_UniChar)))) {
|
||||
return (try - uh);
|
||||
}
|
||||
try--;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
*---------------------------------------------------------------------------
|
||||
*
|
||||
@@ -3592,16 +2948,6 @@ UpdateStringOfString(
|
||||
{
|
||||
String *stringPtr = GET_STRING(objPtr);
|
||||
|
||||
/*
|
||||
* This routine is only called when we need to generate the
|
||||
* string rep objPtr->bytes because it does not exist -- it is NULL.
|
||||
* In that circumstance, any lingering claim about the size of
|
||||
* memory pointed to by that NULL pointer is clearly bogus, and
|
||||
* needs a reset.
|
||||
*/
|
||||
|
||||
stringPtr->allocated = 0;
|
||||
|
||||
if (stringPtr->numChars == 0) {
|
||||
TclInitStringRep(objPtr, tclEmptyStringRep, 0);
|
||||
} else {
|
||||
|
||||
@@ -72,17 +72,17 @@ typedef struct {
|
||||
do { \
|
||||
if ((numChars) < 0 || (numChars) > STRING_MAXCHARS) { \
|
||||
Tcl_Panic("max length for a Tcl unicode value (%d chars) exceeded", \
|
||||
(int)STRING_MAXCHARS); \
|
||||
STRING_MAXCHARS); \
|
||||
} \
|
||||
} while (0)
|
||||
#define stringAttemptAlloc(numChars) \
|
||||
(String *) attemptckalloc(STRING_SIZE(numChars))
|
||||
(String *) attemptckalloc((unsigned) STRING_SIZE(numChars))
|
||||
#define stringAlloc(numChars) \
|
||||
(String *) ckalloc(STRING_SIZE(numChars))
|
||||
(String *) ckalloc((unsigned) STRING_SIZE(numChars))
|
||||
#define stringRealloc(ptr, numChars) \
|
||||
(String *) ckrealloc((ptr), STRING_SIZE(numChars))
|
||||
(String *) ckrealloc((ptr), (unsigned) STRING_SIZE(numChars))
|
||||
#define stringAttemptRealloc(ptr, numChars) \
|
||||
(String *) attemptckrealloc((ptr), STRING_SIZE(numChars))
|
||||
(String *) attemptckrealloc((ptr), (unsigned) STRING_SIZE(numChars))
|
||||
#define GET_STRING(objPtr) \
|
||||
((String *) (objPtr)->internalRep.twoPtrValue.ptr1)
|
||||
#define SET_STRING(objPtr, stringPtr) \
|
||||
|
||||
@@ -749,7 +749,6 @@ const TclTomMathStubs tclTomMathStubs = {
|
||||
TclBNInitBignumFromLong, /* 64 */
|
||||
TclBNInitBignumFromWideInt, /* 65 */
|
||||
TclBNInitBignumFromWideUInt, /* 66 */
|
||||
TclBN_mp_expt_d_ex, /* 67 */
|
||||
};
|
||||
|
||||
static const TclStubHooks tclStubHooks = {
|
||||
|
||||
@@ -101,16 +101,12 @@ Tcl_InitStubs(
|
||||
}
|
||||
}
|
||||
}
|
||||
if (((exact&0xff00) < 0x900)) {
|
||||
/* We are running Tcl 8.x */
|
||||
stubsPtr = (TclStubs *)pkgData;
|
||||
}
|
||||
tclStubsPtr = stubsPtr;
|
||||
tclStubsPtr = (TclStubs *)pkgData;
|
||||
|
||||
if (stubsPtr->hooks) {
|
||||
tclPlatStubsPtr = stubsPtr->hooks->tclPlatStubs;
|
||||
tclIntStubsPtr = stubsPtr->hooks->tclIntStubs;
|
||||
tclIntPlatStubsPtr = stubsPtr->hooks->tclIntPlatStubs;
|
||||
if (tclStubsPtr->hooks) {
|
||||
tclPlatStubsPtr = tclStubsPtr->hooks->tclPlatStubs;
|
||||
tclIntStubsPtr = tclStubsPtr->hooks->tclIntStubs;
|
||||
tclIntPlatStubsPtr = tclStubsPtr->hooks->tclIntPlatStubs;
|
||||
} else {
|
||||
tclPlatStubsPtr = NULL;
|
||||
tclIntStubsPtr = NULL;
|
||||
|
||||
+23
-131
@@ -318,9 +318,6 @@ static int TestparsevarnameObjCmd(ClientData dummy,
|
||||
static int TestpreferstableObjCmd(ClientData dummy,
|
||||
Tcl_Interp *interp, int objc,
|
||||
Tcl_Obj *const objv[]);
|
||||
static int TestprintObjCmd(ClientData dummy,
|
||||
Tcl_Interp *interp, int objc,
|
||||
Tcl_Obj *const objv[]);
|
||||
static int TestregexpObjCmd(ClientData dummy,
|
||||
Tcl_Interp *interp, int objc,
|
||||
Tcl_Obj *const objv[]);
|
||||
@@ -544,10 +541,10 @@ Tcltest_Init(
|
||||
"-appinitprocclosestderr", "-appinitprocsetrcfile", NULL
|
||||
};
|
||||
|
||||
if (Tcl_InitStubs(interp, "8.5-", 0) == NULL) {
|
||||
if (Tcl_InitStubs(interp, "8.5", 0) == NULL) {
|
||||
return TCL_ERROR;
|
||||
}
|
||||
if (Tcl_TomMath_InitStubs(interp, "8.5-") == NULL) {
|
||||
if (Tcl_TomMath_InitStubs(interp, "8.5") == NULL) {
|
||||
return TCL_ERROR;
|
||||
}
|
||||
if (Tcl_OOInitStubs(interp) == NULL) {
|
||||
@@ -652,8 +649,6 @@ Tcltest_Init(
|
||||
NULL, NULL);
|
||||
Tcl_CreateObjCommand(interp, "testpreferstable", TestpreferstableObjCmd,
|
||||
NULL, NULL);
|
||||
Tcl_CreateObjCommand(interp, "testprint", TestprintObjCmd,
|
||||
NULL, NULL);
|
||||
Tcl_CreateObjCommand(interp, "testregexp", TestregexpObjCmd,
|
||||
NULL, NULL);
|
||||
Tcl_CreateObjCommand(interp, "testreturn", TestreturnObjCmd,
|
||||
@@ -786,7 +781,7 @@ int
|
||||
Tcltest_SafeInit(
|
||||
Tcl_Interp *interp) /* Interpreter for application. */
|
||||
{
|
||||
if (Tcl_InitStubs(interp, "8.5-", 0) == NULL) {
|
||||
if (Tcl_InitStubs(interp, "8.5", 0) == NULL) {
|
||||
return TCL_ERROR;
|
||||
}
|
||||
return Procbodytest_SafeInit(interp);
|
||||
@@ -3822,43 +3817,6 @@ TestpreferstableObjCmd(
|
||||
return TCL_OK;
|
||||
}
|
||||
|
||||
/*
|
||||
*----------------------------------------------------------------------
|
||||
*
|
||||
* TestprintObjCmd --
|
||||
*
|
||||
* This procedure implements the "testprint" command. It is
|
||||
* used for being able to test the Tcl_ObjPrintf() function.
|
||||
*
|
||||
* Results:
|
||||
* A standard Tcl result.
|
||||
*
|
||||
* Side effects:
|
||||
* None.
|
||||
*
|
||||
*----------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
static int
|
||||
TestprintObjCmd(
|
||||
ClientData clientData, /* Not used. */
|
||||
Tcl_Interp *interp, /* Current interpreter. */
|
||||
int objc, /* Number of arguments. */
|
||||
Tcl_Obj *const objv[]) /* The argument objects. */
|
||||
{
|
||||
Tcl_WideInt argv1 = 0;
|
||||
|
||||
if (objc < 2 || objc > 3) {
|
||||
Tcl_WrongNumArgs(interp, 1, objv, "format wideint");
|
||||
}
|
||||
|
||||
if (objc > 1) {
|
||||
Tcl_GetWideIntFromObj(interp, objv[2], &argv1);
|
||||
}
|
||||
Tcl_SetObjResult(interp, Tcl_ObjPrintf(Tcl_GetString(objv[1]), argv1));
|
||||
return TCL_OK;
|
||||
}
|
||||
|
||||
/*
|
||||
*----------------------------------------------------------------------
|
||||
*
|
||||
@@ -4639,7 +4597,7 @@ TestpanicCmd(
|
||||
int argc, /* Number of arguments. */
|
||||
const char **argv) /* Argument strings. */
|
||||
{
|
||||
char *argString;
|
||||
const char *argString;
|
||||
|
||||
/*
|
||||
* Put the arguments into a var args structure
|
||||
@@ -6793,7 +6751,7 @@ TestcpuidCmd(
|
||||
Tcl_Obj *const * objv) /* Parameter vector */
|
||||
{
|
||||
int status, index, i;
|
||||
int regs[4];
|
||||
unsigned int regs[4];
|
||||
Tcl_Obj *regsObjs[4];
|
||||
|
||||
if (objc != 2) {
|
||||
@@ -6803,14 +6761,14 @@ TestcpuidCmd(
|
||||
if (Tcl_GetIntFromObj(interp, objv[1], &index) != TCL_OK) {
|
||||
return TCL_ERROR;
|
||||
}
|
||||
status = TclWinCPUID(index, regs);
|
||||
status = TclWinCPUID((unsigned) index, regs);
|
||||
if (status != TCL_OK) {
|
||||
Tcl_SetObjResult(interp,
|
||||
Tcl_NewStringObj("operation not available", -1));
|
||||
return status;
|
||||
}
|
||||
for (i=0 ; i<4 ; ++i) {
|
||||
regsObjs[i] = Tcl_NewIntObj(regs[i]);
|
||||
regsObjs[i] = Tcl_NewIntObj((int) regs[i]);
|
||||
}
|
||||
Tcl_SetObjResult(interp, Tcl_NewListObj(4, regsObjs));
|
||||
return TCL_OK;
|
||||
@@ -7368,82 +7326,23 @@ InterpCmdResolver(
|
||||
CallFrame *varFramePtr = iPtr->varFramePtr;
|
||||
Proc *procPtr = (varFramePtr->isProcCallFrame & FRAME_IS_PROC) ?
|
||||
varFramePtr->procPtr : NULL;
|
||||
Namespace *callerNsPtr = varFramePtr->nsPtr;
|
||||
Tcl_Command resolvedCmdPtr = NULL;
|
||||
Namespace *ns2NsPtr = (Namespace *)
|
||||
Tcl_FindNamespace(interp, "::ns2", NULL, 0);
|
||||
|
||||
/*
|
||||
* Just do something special on a cmd literal "z" in two cases:
|
||||
* A) when the caller is a proc "x", and the proc is either in "::" or in "::ns2".
|
||||
* B) the caller's namespace is "ctx1" or "ctx2"
|
||||
*/
|
||||
if ( (name[0] == 'z') && (name[1] == '\0') ) {
|
||||
Namespace *ns2NsPtr = (Namespace *) Tcl_FindNamespace(interp, "::ns2", NULL, 0);
|
||||
|
||||
if (procPtr != NULL
|
||||
&& ((procPtr->cmdPtr->nsPtr == iPtr->globalNsPtr)
|
||||
|| (ns2NsPtr != NULL && procPtr->cmdPtr->nsPtr == ns2NsPtr)
|
||||
)
|
||||
) {
|
||||
/*
|
||||
* Case A)
|
||||
*
|
||||
* - The context, in which this resolver becomes active, is
|
||||
* determined by the name of the caller proc, which has to be
|
||||
* named "x".
|
||||
*
|
||||
* - To determine the name of the caller proc, the proc is taken
|
||||
* from the topmost stack frame.
|
||||
*
|
||||
* - Note that the context is NOT provided during byte-code
|
||||
* compilation (e.g. in TclProcCompileProc)
|
||||
*
|
||||
* When these conditions hold, this function resolves the
|
||||
* passed-in cmd literal into a cmd "y", which is taken from the
|
||||
* the global namespace (for simplicity).
|
||||
*/
|
||||
|
||||
const char *callingCmdName =
|
||||
if (procPtr && (procPtr->cmdPtr->nsPtr == iPtr->globalNsPtr
|
||||
|| (ns2NsPtr && procPtr->cmdPtr->nsPtr == ns2NsPtr))) {
|
||||
const char *callingCmdName =
|
||||
Tcl_GetCommandName(interp, (Tcl_Command) procPtr->cmdPtr);
|
||||
|
||||
if ( callingCmdName[0] == 'x' && callingCmdName[1] == '\0' ) {
|
||||
resolvedCmdPtr = Tcl_FindCommand(interp, "y", NULL, TCL_GLOBAL_ONLY);
|
||||
if ((callingCmdName[0] == 'x') && (callingCmdName[1] == '\0')
|
||||
&& (name[0] == 'z') && (name[1] == '\0')) {
|
||||
Tcl_Command sourceCmdPtr = Tcl_FindCommand(interp, "y", NULL,
|
||||
TCL_GLOBAL_ONLY);
|
||||
|
||||
if (sourceCmdPtr != NULL) {
|
||||
*rPtr = sourceCmdPtr;
|
||||
return TCL_OK;
|
||||
}
|
||||
} else if (callerNsPtr != NULL) {
|
||||
/*
|
||||
* Case B)
|
||||
*
|
||||
* - The context, in which this resolver becomes active, is
|
||||
* determined by the name of the parent namespace, which has
|
||||
* to be named "ctx1" or "ctx2".
|
||||
*
|
||||
* - To determine the name of the parent namesace, it is taken
|
||||
* from the 2nd highest stack frame.
|
||||
*
|
||||
* - Note that the context can be provided during byte-code
|
||||
* compilation (e.g. in TclProcCompileProc)
|
||||
*
|
||||
* When these conditions hold, this function resolves the
|
||||
* passed-in cmd literal into a cmd "y" or "Y" depending on the
|
||||
* context. The resolved procs are taken from the the global
|
||||
* namespace (for simplicity).
|
||||
*/
|
||||
|
||||
CallFrame *parentFramePtr = varFramePtr->callerPtr;
|
||||
char *context = parentFramePtr != NULL ? parentFramePtr->nsPtr->name : "(NULL)";
|
||||
|
||||
if (strcmp(context, "ctx1") == 0 && (name[0] == 'z') && (name[1] == '\0')) {
|
||||
resolvedCmdPtr = Tcl_FindCommand(interp, "y", NULL, TCL_GLOBAL_ONLY);
|
||||
/* fprintf(stderr, "... y ==> %p\n", resolvedCmdPtr);*/
|
||||
|
||||
} else if (strcmp(context, "ctx2") == 0 && (name[0] == 'z') && (name[1] == '\0')) {
|
||||
resolvedCmdPtr = Tcl_FindCommand(interp, "Y", NULL, TCL_GLOBAL_ONLY);
|
||||
/*fprintf(stderr, "... Y ==> %p\n", resolvedCmdPtr);*/
|
||||
}
|
||||
}
|
||||
|
||||
if (resolvedCmdPtr != NULL) {
|
||||
*rPtr = resolvedCmdPtr;
|
||||
return TCL_OK;
|
||||
}
|
||||
}
|
||||
return TCL_CONTINUE;
|
||||
@@ -7577,16 +7476,9 @@ TestInterpResolverCmd(
|
||||
int idx;
|
||||
#define RESOLVER_KEY "testInterpResolver"
|
||||
|
||||
if ((objc < 2) || (objc > 3)) {
|
||||
Tcl_WrongNumArgs(interp, 1, objv, "up|down ?interp?");
|
||||
return TCL_ERROR;
|
||||
}
|
||||
if (objc == 3) {
|
||||
interp = Tcl_GetSlave(interp, Tcl_GetString(objv[2]));
|
||||
if (interp == NULL) {
|
||||
Tcl_AppendResult(interp, "provided interpreter not found", NULL);
|
||||
return TCL_ERROR;
|
||||
}
|
||||
if (objc != 2) {
|
||||
Tcl_WrongNumArgs(interp, 1, objv, "up|down");
|
||||
return TCL_ERROR;
|
||||
}
|
||||
if (Tcl_GetIndexFromObj(interp, objv[1], table, "operation", TCL_EXACT,
|
||||
&idx) != TCL_OK) {
|
||||
|
||||
+3
-48
@@ -152,11 +152,10 @@ TestbignumobjCmd(
|
||||
Tcl_Obj *const objv[]) /* Argument vector */
|
||||
{
|
||||
const char *const subcmds[] = {
|
||||
"set", "get", "mult10", "div10", "iseven", "radixsize", NULL
|
||||
"set", "get", "mult10", "div10", NULL
|
||||
};
|
||||
enum options {
|
||||
BIGNUM_SET, BIGNUM_GET, BIGNUM_MULT10, BIGNUM_DIV10, BIGNUM_ISEVEN,
|
||||
BIGNUM_RADIXSIZE
|
||||
BIGNUM_SET, BIGNUM_GET, BIGNUM_MULT10, BIGNUM_DIV10
|
||||
};
|
||||
int index, varIndex;
|
||||
const char *string;
|
||||
@@ -275,50 +274,6 @@ TestbignumobjCmd(
|
||||
} else {
|
||||
SetVarToObj(varPtr, varIndex, Tcl_NewBignumObj(&newValue));
|
||||
}
|
||||
break;
|
||||
|
||||
case BIGNUM_ISEVEN:
|
||||
if (objc != 3) {
|
||||
Tcl_WrongNumArgs(interp, 2, objv, "varIndex");
|
||||
return TCL_ERROR;
|
||||
}
|
||||
if (CheckIfVarUnset(interp, varPtr,varIndex)) {
|
||||
return TCL_ERROR;
|
||||
}
|
||||
if (Tcl_GetBignumFromObj(interp, varPtr[varIndex],
|
||||
&bignumValue) != TCL_OK) {
|
||||
return TCL_ERROR;
|
||||
}
|
||||
if (!Tcl_IsShared(varPtr[varIndex])) {
|
||||
Tcl_SetIntObj(varPtr[varIndex], mp_iseven(&bignumValue));
|
||||
} else {
|
||||
SetVarToObj(varPtr, varIndex, Tcl_NewIntObj(mp_iseven(&bignumValue)));
|
||||
}
|
||||
mp_clear(&bignumValue);
|
||||
break;
|
||||
|
||||
case BIGNUM_RADIXSIZE:
|
||||
if (objc != 3) {
|
||||
Tcl_WrongNumArgs(interp, 2, objv, "varIndex");
|
||||
return TCL_ERROR;
|
||||
}
|
||||
if (CheckIfVarUnset(interp, varPtr,varIndex)) {
|
||||
return TCL_ERROR;
|
||||
}
|
||||
if (Tcl_GetBignumFromObj(interp, varPtr[varIndex],
|
||||
&bignumValue) != TCL_OK) {
|
||||
return TCL_ERROR;
|
||||
}
|
||||
if (mp_radix_size(&bignumValue, 10, &index) != MP_OKAY) {
|
||||
return TCL_ERROR;
|
||||
}
|
||||
if (!Tcl_IsShared(varPtr[varIndex])) {
|
||||
Tcl_SetIntObj(varPtr[varIndex], index);
|
||||
} else {
|
||||
SetVarToObj(varPtr, varIndex, Tcl_NewIntObj(index));
|
||||
}
|
||||
mp_clear(&bignumValue);
|
||||
break;
|
||||
}
|
||||
|
||||
Tcl_SetObjResult(interp, varPtr[varIndex]);
|
||||
@@ -1101,7 +1056,7 @@ TestobjCmd(
|
||||
if (CheckIfVarUnset(interp, varPtr,varIndex)) {
|
||||
return TCL_ERROR;
|
||||
}
|
||||
Tcl_SetObjResult(interp, Tcl_NewWideIntObj(varPtr[varIndex]->refCount));
|
||||
Tcl_SetObjResult(interp, Tcl_NewIntObj(varPtr[varIndex]->refCount));
|
||||
} else if (strcmp(subCmd, "type") == 0) {
|
||||
if (objc != 3) {
|
||||
goto wrongNumArgs;
|
||||
|
||||
@@ -1106,9 +1106,9 @@ TclFinalizeThreadAlloc(void)
|
||||
*
|
||||
* TclFinalizeThreadAllocThread --
|
||||
*
|
||||
* This procedure is used to destroy single thread private resources
|
||||
* defined in this file. Called either during Tcl_FinalizeThread() or
|
||||
* Tcl_Finalize().
|
||||
* This procedure is used to destroy single thread private resources used
|
||||
* in this file.
|
||||
* Called in TclpFinalizeThreadData when a thread exits (Tcl_FinalizeThread).
|
||||
*
|
||||
* Results:
|
||||
* None.
|
||||
|
||||
@@ -90,7 +90,7 @@ declare 21 {
|
||||
int TclBN_mp_init(mp_int *a)
|
||||
}
|
||||
declare 22 {
|
||||
int TclBN_mp_init_copy(mp_int *a, const mp_int *b)
|
||||
int TclBN_mp_init_copy(mp_int *a, mp_int *b)
|
||||
}
|
||||
declare 23 {
|
||||
int TclBN_mp_init_multi(mp_int *a, ...)
|
||||
@@ -129,7 +129,7 @@ declare 34 {
|
||||
int TclBN_mp_or(mp_int *a, mp_int *b, mp_int *c)
|
||||
}
|
||||
declare 35 {
|
||||
int TclBN_mp_radix_size(const mp_int *a, int radix, int *size)
|
||||
int TclBN_mp_radix_size(mp_int *a, int radix, int *size)
|
||||
}
|
||||
declare 36 {
|
||||
int TclBN_mp_read_radix(mp_int *a, const char *str, int radix)
|
||||
@@ -233,11 +233,6 @@ declare 66 {
|
||||
void TclBNInitBignumFromWideUInt(mp_int *bignum, Tcl_WideUInt initVal)
|
||||
}
|
||||
|
||||
# Added in libtommath 1.0
|
||||
declare 67 {
|
||||
int TclBN_mp_expt_d_ex(mp_int *a, mp_digit b, mp_int *c, int fast)
|
||||
}
|
||||
|
||||
# Local Variables:
|
||||
# mode: tcl
|
||||
# End:
|
||||
|
||||
+153
-123
@@ -10,7 +10,7 @@
|
||||
* The library is free for all purposes without any express
|
||||
* guarantee it works.
|
||||
*
|
||||
* Tom St Denis, tstdenis82@gmail.com, http://math.libtomcrypt.com
|
||||
* Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com
|
||||
*/
|
||||
#ifndef BN_H_
|
||||
#define BN_H_
|
||||
@@ -22,15 +22,33 @@
|
||||
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#ifndef MIN
|
||||
# define MIN(x,y) ((x)<(y)?(x):(y))
|
||||
#endif
|
||||
|
||||
#ifndef MAX
|
||||
# define MAX(x,y) ((x)>(y)?(x):(y))
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
|
||||
/* C++ compilers don't like assigning void * to mp_digit * */
|
||||
#define OPT_CAST(x) (x *)
|
||||
|
||||
#else
|
||||
|
||||
/* C on the other hand doesn't care */
|
||||
#define OPT_CAST(x)
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
/* detect 64-bit mode if possible */
|
||||
#if defined(NEVER) /* 128-bit ints fail in too many places */
|
||||
#if !(defined(MP_32BIT) || defined(MP_16BIT) || defined(MP_8BIT))
|
||||
#define MP_64BIT
|
||||
#endif
|
||||
#if defined(NEVER) /* 128-bit ints fail in too many places */
|
||||
# if !(defined(MP_64BIT) && defined(MP_16BIT) && defined(MP_8BIT))
|
||||
# define MP_64BIT
|
||||
# endif
|
||||
#endif
|
||||
|
||||
/* some default configurations.
|
||||
@@ -43,89 +61,83 @@ extern "C" {
|
||||
*/
|
||||
#ifdef MP_8BIT
|
||||
#ifndef MP_DIGIT_DECLARED
|
||||
typedef uint8_t mp_digit;
|
||||
typedef unsigned char mp_digit;
|
||||
#define MP_DIGIT_DECLARED
|
||||
#endif
|
||||
typedef uint16_t mp_word;
|
||||
#define MP_SIZEOF_MP_DIGIT 1
|
||||
#ifdef DIGIT_BIT
|
||||
#error You must not define DIGIT_BIT when using MP_8BIT
|
||||
#endif
|
||||
typedef unsigned short mp_word;
|
||||
#elif defined(MP_16BIT)
|
||||
#ifndef MP_DIGIT_DECLARED
|
||||
typedef uint16_t mp_digit;
|
||||
typedef unsigned short mp_digit;
|
||||
#define MP_DIGIT_DECLARED
|
||||
#endif
|
||||
typedef uint32_t mp_word;
|
||||
#define MP_SIZEOF_MP_DIGIT 2
|
||||
#ifdef DIGIT_BIT
|
||||
#error You must not define DIGIT_BIT when using MP_16BIT
|
||||
#endif
|
||||
typedef unsigned long mp_word;
|
||||
#elif defined(MP_64BIT)
|
||||
/* for GCC only on supported platforms */
|
||||
#ifndef CRYPT
|
||||
typedef unsigned long long ulong64;
|
||||
typedef signed long long long64;
|
||||
typedef unsigned long long ulong64;
|
||||
typedef signed long long long64;
|
||||
#endif
|
||||
|
||||
#ifndef MP_DIGIT_DECLARED
|
||||
typedef ulong64 mp_digit;
|
||||
typedef unsigned long mp_digit;
|
||||
#define MP_DIGIT_DECLARED
|
||||
#endif
|
||||
#if defined(_WIN32)
|
||||
typedef unsigned __int128 mp_word;
|
||||
#elif defined(__GNUC__)
|
||||
typedef unsigned long mp_word __attribute__ ((mode(TI)));
|
||||
#else
|
||||
/* it seems you have a problem
|
||||
* but we assume you can somewhere define your own uint128_t */
|
||||
typedef uint128_t mp_word;
|
||||
#endif
|
||||
typedef unsigned long mp_word __attribute__ ((mode(TI)));
|
||||
|
||||
#define DIGIT_BIT 60
|
||||
# define DIGIT_BIT 60
|
||||
#else
|
||||
/* this is the default case, 28-bit digits */
|
||||
|
||||
|
||||
/* this is to make porting into LibTomCrypt easier :-) */
|
||||
#ifndef CRYPT
|
||||
typedef unsigned long long ulong64;
|
||||
typedef signed long long long64;
|
||||
# if defined(_MSC_VER) || defined(__BORLANDC__)
|
||||
typedef unsigned __int64 ulong64;
|
||||
typedef signed __int64 long64;
|
||||
# else
|
||||
typedef unsigned long long ulong64;
|
||||
typedef signed long long long64;
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#ifndef MP_DIGIT_DECLARED
|
||||
typedef uint32_t mp_digit;
|
||||
typedef unsigned int mp_digit;
|
||||
#define MP_DIGIT_DECLARED
|
||||
#endif
|
||||
typedef ulong64 mp_word;
|
||||
typedef ulong64 mp_word;
|
||||
|
||||
#ifdef MP_31BIT
|
||||
#ifdef MP_31BIT
|
||||
/* this is an extension that uses 31-bit digits */
|
||||
#define DIGIT_BIT 31
|
||||
# define DIGIT_BIT 31
|
||||
#else
|
||||
/* default case is 28-bit digits, defines MP_28BIT as a handy macro to test */
|
||||
#define DIGIT_BIT 28
|
||||
#define MP_28BIT
|
||||
# define DIGIT_BIT 28
|
||||
# define MP_28BIT
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/* define heap macros */
|
||||
#if 0 /* these are macros in tclTomMathDecls.h */
|
||||
#ifndef CRYPT
|
||||
/* default to libc stuff */
|
||||
# ifndef XMALLOC
|
||||
# define XMALLOC malloc
|
||||
# define XFREE free
|
||||
# define XREALLOC realloc
|
||||
# define XCALLOC calloc
|
||||
# else
|
||||
/* prototypes for our heap functions */
|
||||
extern void *XMALLOC(size_t n);
|
||||
extern void *XREALLOC(void *p, size_t n);
|
||||
extern void *XCALLOC(size_t n, size_t s);
|
||||
extern void XFREE(void *p);
|
||||
# endif
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
||||
/* otherwise the bits per digit is calculated automatically from the size of a mp_digit */
|
||||
#ifndef DIGIT_BIT
|
||||
#define DIGIT_BIT (((CHAR_BIT * MP_SIZEOF_MP_DIGIT) - 1)) /* bits per digit */
|
||||
typedef uint_least32_t mp_min_u32;
|
||||
#else
|
||||
typedef mp_digit mp_min_u32;
|
||||
#endif
|
||||
|
||||
/* platforms that can use a better rand function */
|
||||
#if defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__NetBSD__) || defined(__DragonFly__)
|
||||
#define MP_USE_ALT_RAND 1
|
||||
#endif
|
||||
|
||||
/* use arc4random on platforms that support it */
|
||||
#ifdef MP_USE_ALT_RAND
|
||||
#define MP_GEN_RANDOM() arc4random()
|
||||
#else
|
||||
#define MP_GEN_RANDOM() rand()
|
||||
# define DIGIT_BIT ((int)((CHAR_BIT * sizeof(mp_digit) - 1))) /* bits per digit */
|
||||
#endif
|
||||
|
||||
#define MP_DIGIT_BIT DIGIT_BIT
|
||||
@@ -168,15 +180,15 @@ MODULE_SCOPE int KARATSUBA_MUL_CUTOFF,
|
||||
|
||||
/* default precision */
|
||||
#ifndef MP_PREC
|
||||
#ifndef MP_LOW_MEM
|
||||
#define MP_PREC 32 /* default digits of precision */
|
||||
#else
|
||||
#define MP_PREC 8 /* default digits of precision */
|
||||
#endif
|
||||
# ifndef MP_LOW_MEM
|
||||
# define MP_PREC 32 /* default digits of precision */
|
||||
# else
|
||||
# define MP_PREC 8 /* default digits of precision */
|
||||
# endif
|
||||
#endif
|
||||
|
||||
/* size of comba arrays, should be at least 2 * 2**(BITS_PER_WORD - BITS_PER_DIGIT*2) */
|
||||
#define MP_WARRAY (1 << (((sizeof(mp_word) * CHAR_BIT) - (2 * DIGIT_BIT)) + 1))
|
||||
#define MP_WARRAY (1 << (sizeof(mp_word) * CHAR_BIT - 2 * DIGIT_BIT + 1))
|
||||
|
||||
/* the infamous mp_int structure */
|
||||
#ifndef MP_INT_DECLARED
|
||||
@@ -197,7 +209,9 @@ typedef int ltm_prime_callback(unsigned char *dst, int len, void *dat);
|
||||
#define SIGN(m) ((m)->sign)
|
||||
|
||||
/* error code to char* string */
|
||||
const char *mp_error_to_string(int code);
|
||||
/*
|
||||
char *mp_error_to_string(int code);
|
||||
*/
|
||||
|
||||
/* ---> init and deinit bignum functions <--- */
|
||||
/* init a bignum */
|
||||
@@ -242,9 +256,8 @@ int mp_init_size(mp_int *a, int size);
|
||||
|
||||
/* ---> Basic Manipulations <--- */
|
||||
#define mp_iszero(a) (((a)->used == 0) ? MP_YES : MP_NO)
|
||||
#define mp_iseven(a) ((((a)->used == 0) || (((a)->dp[0] & 1u) == 0u)) ? MP_YES : MP_NO)
|
||||
#define mp_isodd(a) ((((a)->used > 0) && (((a)->dp[0] & 1u) == 1u)) ? MP_YES : MP_NO)
|
||||
#define mp_isneg(a) (((a)->sign != MP_ZPOS) ? MP_YES : MP_NO)
|
||||
#define mp_iseven(a) (((a)->used == 0 || (((a)->dp[0] & 1) == 0)) ? MP_YES : MP_NO)
|
||||
#define mp_isodd(a) (((a)->used > 0 && (((a)->dp[0] & 1) == 1)) ? MP_YES : MP_NO)
|
||||
|
||||
/* set to zero */
|
||||
/*
|
||||
@@ -261,25 +274,9 @@ void mp_set(mp_int *a, mp_digit b);
|
||||
int mp_set_int(mp_int *a, unsigned long b);
|
||||
*/
|
||||
|
||||
/* set a platform dependent unsigned long value */
|
||||
/*
|
||||
int mp_set_long(mp_int *a, unsigned long b);
|
||||
*/
|
||||
|
||||
/* set a platform dependent unsigned long long value */
|
||||
/*
|
||||
int mp_set_long_long(mp_int *a, unsigned long long b);
|
||||
*/
|
||||
|
||||
/* get a 32-bit value */
|
||||
unsigned long mp_get_int(mp_int * a);
|
||||
|
||||
/* get a platform dependent unsigned long value */
|
||||
unsigned long mp_get_long(mp_int * a);
|
||||
|
||||
/* get a platform dependent unsigned long long value */
|
||||
unsigned long long mp_get_long_long(mp_int * a);
|
||||
|
||||
/* initialize and set a digit */
|
||||
/*
|
||||
int mp_init_set (mp_int * a, mp_digit b);
|
||||
@@ -297,7 +294,7 @@ int mp_copy(const mp_int *a, mp_int *b);
|
||||
|
||||
/* inits and copies, a = b */
|
||||
/*
|
||||
int mp_init_copy(mp_int *a, const mp_int *b);
|
||||
int mp_init_copy(mp_int *a, mp_int *b);
|
||||
*/
|
||||
|
||||
/* trim unused digits */
|
||||
@@ -305,16 +302,6 @@ int mp_init_copy(mp_int *a, const mp_int *b);
|
||||
void mp_clamp(mp_int *a);
|
||||
*/
|
||||
|
||||
/* import binary data */
|
||||
/*
|
||||
int mp_import(mp_int* rop, size_t count, int order, size_t size, int endian, size_t nails, const void* op);
|
||||
*/
|
||||
|
||||
/* export binary data */
|
||||
/*
|
||||
int mp_export(void* rop, size_t* countp, int order, size_t size, int endian, size_t nails, mp_int* op);
|
||||
*/
|
||||
|
||||
/* ---> digit manipulation <--- */
|
||||
|
||||
/* right shift by "b" digits */
|
||||
@@ -327,7 +314,7 @@ void mp_rshd(mp_int *a, int b);
|
||||
int mp_lshd(mp_int *a, int b);
|
||||
*/
|
||||
|
||||
/* c = a / 2**b, implemented as c = a >> b */
|
||||
/* c = a / 2**b */
|
||||
/*
|
||||
int mp_div_2d(const mp_int *a, int b, mp_int *c, mp_int *d);
|
||||
*/
|
||||
@@ -337,7 +324,7 @@ int mp_div_2d(const mp_int *a, int b, mp_int *c, mp_int *d);
|
||||
int mp_div_2(mp_int *a, mp_int *b);
|
||||
*/
|
||||
|
||||
/* c = a * 2**b, implemented as c = a << b */
|
||||
/* c = a * 2**b */
|
||||
/*
|
||||
int mp_mul_2d(const mp_int *a, int b, mp_int *c);
|
||||
*/
|
||||
@@ -347,7 +334,7 @@ int mp_mul_2d(const mp_int *a, int b, mp_int *c);
|
||||
int mp_mul_2(mp_int *a, mp_int *b);
|
||||
*/
|
||||
|
||||
/* c = a mod 2**b */
|
||||
/* c = a mod 2**d */
|
||||
/*
|
||||
int mp_mod_2d(const mp_int *a, int b, mp_int *c);
|
||||
*/
|
||||
@@ -359,7 +346,7 @@ int mp_2expt(mp_int *a, int b);
|
||||
|
||||
/* Counts the number of lsbs which are zero before the first zero bit */
|
||||
/*
|
||||
int mp_cnt_lsb(const mp_int *a);
|
||||
int mp_cnt_lsb(mp_int *a);
|
||||
*/
|
||||
|
||||
/* I Love Earth! */
|
||||
@@ -473,9 +460,6 @@ int mp_div_3(mp_int *a, mp_int *c, mp_digit *d);
|
||||
/*
|
||||
int mp_expt_d(mp_int *a, mp_digit b, mp_int *c);
|
||||
*/
|
||||
/*
|
||||
int mp_expt_d_ex (mp_int * a, mp_digit b, mp_int * c, int fast);
|
||||
*/
|
||||
|
||||
/* c = a mod b, 0 <= c < b */
|
||||
/*
|
||||
@@ -531,20 +515,12 @@ int mp_lcm(mp_int *a, mp_int *b, mp_int *c);
|
||||
/*
|
||||
int mp_n_root(mp_int *a, mp_digit b, mp_int *c);
|
||||
*/
|
||||
/*
|
||||
int mp_n_root_ex (mp_int * a, mp_digit b, mp_int * c, int fast);
|
||||
*/
|
||||
|
||||
/* special sqrt algo */
|
||||
/*
|
||||
int mp_sqrt(mp_int *arg, mp_int *ret);
|
||||
*/
|
||||
|
||||
/* special sqrt (mod prime) */
|
||||
/*
|
||||
int mp_sqrtmod_prime(mp_int *arg, mp_int *prime, mp_int *ret);
|
||||
*/
|
||||
|
||||
/* is number a square? */
|
||||
/*
|
||||
int mp_is_square(mp_int *arg, int *ret);
|
||||
@@ -647,7 +623,7 @@ int mp_exptmod(mp_int *a, mp_int *b, mp_int *c, mp_int *d);
|
||||
|
||||
/* table of first PRIME_SIZE primes */
|
||||
#if defined(BUILD_tcl) || !defined(_WIN32)
|
||||
MODULE_SCOPE const mp_digit ltm_prime_tab[PRIME_SIZE];
|
||||
MODULE_SCOPE const mp_digit ltm_prime_tab[];
|
||||
#endif
|
||||
|
||||
/* result=1 if a is divisible by one of the first PRIME_SIZE primes */
|
||||
@@ -670,7 +646,7 @@ int mp_prime_miller_rabin(mp_int *a, mp_int *b, int *result);
|
||||
*/
|
||||
|
||||
/* This gives [for a given bit size] the number of trials required
|
||||
* such that Miller-Rabin gives a prob of failure lower than 2^-96
|
||||
* such that Miller-Rabin gives a prob of failure lower than 2^-96
|
||||
*/
|
||||
/*
|
||||
int mp_prime_rabin_miller_trials(int size);
|
||||
@@ -697,7 +673,7 @@ int mp_prime_next_prime(mp_int *a, int t, int bbs_style);
|
||||
*/
|
||||
|
||||
/* makes a truly random prime of a given size (bytes),
|
||||
* call with bbs = 1 if you want it to be congruent to 3 mod 4
|
||||
* call with bbs = 1 if you want it to be congruent to 3 mod 4
|
||||
*
|
||||
* You have to supply a callback which fills in a buffer with random bytes. "dat" is a parameter you can
|
||||
* have passed to the callback (e.g. a state or something). This function doesn't use "dat" itself
|
||||
@@ -710,9 +686,10 @@ int mp_prime_next_prime(mp_int *a, int t, int bbs_style);
|
||||
/* makes a truly random prime of a given size (bits),
|
||||
*
|
||||
* Flags are as follows:
|
||||
*
|
||||
*
|
||||
* LTM_PRIME_BBS - make prime congruent to 3 mod 4
|
||||
* LTM_PRIME_SAFE - make sure (p-1)/2 is prime as well (implies LTM_PRIME_BBS)
|
||||
* LTM_PRIME_2MSB_OFF - make the 2nd highest bit zero
|
||||
* LTM_PRIME_2MSB_ON - make the 2nd highest bit one
|
||||
*
|
||||
* You have to supply a callback which fills in a buffer with random bytes. "dat" is a parameter you can
|
||||
@@ -765,17 +742,15 @@ int mp_toradix(mp_int *a, char *str, int radix);
|
||||
int mp_toradix_n(mp_int * a, char *str, int radix, int maxlen);
|
||||
*/
|
||||
/*
|
||||
int mp_radix_size(const mp_int *a, int radix, int *size);
|
||||
int mp_radix_size(mp_int *a, int radix, int *size);
|
||||
*/
|
||||
|
||||
#ifndef LTM_NO_FILE
|
||||
/*
|
||||
int mp_fread(mp_int *a, int radix, FILE *stream);
|
||||
*/
|
||||
/*
|
||||
int mp_fwrite(mp_int *a, int radix, FILE *stream);
|
||||
*/
|
||||
#endif
|
||||
|
||||
#define mp_read_raw(mp, str, len) mp_read_signed_bin((mp), (str), (len))
|
||||
#define mp_raw_size(mp) mp_signed_bin_size(mp)
|
||||
@@ -789,14 +764,69 @@ int mp_fwrite(mp_int *a, int radix, FILE *stream);
|
||||
#define mp_todecimal(M, S) mp_toradix((M), (S), 10)
|
||||
#define mp_tohex(M, S) mp_toradix((M), (S), 16)
|
||||
|
||||
/* lowlevel functions, do not call! */
|
||||
/*
|
||||
int s_mp_add(mp_int *a, mp_int *b, mp_int *c);
|
||||
*/
|
||||
/*
|
||||
int s_mp_sub(mp_int *a, mp_int *b, mp_int *c);
|
||||
*/
|
||||
#define s_mp_mul(a, b, c) s_mp_mul_digs(a, b, c, (a)->used + (b)->used + 1)
|
||||
/*
|
||||
int fast_s_mp_mul_digs(mp_int *a, mp_int *b, mp_int *c, int digs);
|
||||
*/
|
||||
/*
|
||||
int s_mp_mul_digs(mp_int *a, mp_int *b, mp_int *c, int digs);
|
||||
*/
|
||||
/*
|
||||
int fast_s_mp_mul_high_digs(mp_int *a, mp_int *b, mp_int *c, int digs);
|
||||
*/
|
||||
/*
|
||||
int s_mp_mul_high_digs(mp_int *a, mp_int *b, mp_int *c, int digs);
|
||||
*/
|
||||
/*
|
||||
int fast_s_mp_sqr(mp_int *a, mp_int *b);
|
||||
*/
|
||||
/*
|
||||
int s_mp_sqr(mp_int *a, mp_int *b);
|
||||
*/
|
||||
/*
|
||||
int mp_karatsuba_mul(mp_int *a, mp_int *b, mp_int *c);
|
||||
*/
|
||||
/*
|
||||
int mp_toom_mul(mp_int *a, mp_int *b, mp_int *c);
|
||||
*/
|
||||
/*
|
||||
int mp_karatsuba_sqr(mp_int *a, mp_int *b);
|
||||
*/
|
||||
/*
|
||||
int mp_toom_sqr(mp_int *a, mp_int *b);
|
||||
*/
|
||||
/*
|
||||
int fast_mp_invmod(mp_int *a, mp_int *b, mp_int *c);
|
||||
*/
|
||||
/*
|
||||
int mp_invmod_slow (mp_int * a, mp_int * b, mp_int * c);
|
||||
*/
|
||||
/*
|
||||
int fast_mp_montgomery_reduce(mp_int *a, mp_int *m, mp_digit mp);
|
||||
*/
|
||||
/*
|
||||
int mp_exptmod_fast(mp_int *G, mp_int *X, mp_int *P, mp_int *Y, int mode);
|
||||
*/
|
||||
/*
|
||||
int s_mp_exptmod (mp_int * G, mp_int * X, mp_int * P, mp_int * Y, int mode);
|
||||
*/
|
||||
/*
|
||||
void bn_reverse(unsigned char *s, int len);
|
||||
*/
|
||||
|
||||
#if defined(BUILD_tcl) || !defined(_WIN32)
|
||||
MODULE_SCOPE const char *mp_s_rmap;
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
/* $Source$ */
|
||||
/* $Revision$ */
|
||||
/* $Date$ */
|
||||
|
||||
|
||||
@@ -73,7 +73,6 @@
|
||||
#define mp_div_d TclBN_mp_div_d
|
||||
#define mp_exch TclBN_mp_exch
|
||||
#define mp_expt_d TclBN_mp_expt_d
|
||||
#define mp_expt_d_ex TclBN_mp_expt_d_ex
|
||||
#define mp_grow TclBN_mp_grow
|
||||
#define mp_init TclBN_mp_init
|
||||
#define mp_init_copy TclBN_mp_init_copy
|
||||
@@ -191,7 +190,7 @@ EXTERN int TclBN_mp_grow(mp_int *a, int size);
|
||||
/* 21 */
|
||||
EXTERN int TclBN_mp_init(mp_int *a);
|
||||
/* 22 */
|
||||
EXTERN int TclBN_mp_init_copy(mp_int *a, const mp_int *b);
|
||||
EXTERN int TclBN_mp_init_copy(mp_int *a, mp_int *b);
|
||||
/* 23 */
|
||||
EXTERN int TclBN_mp_init_multi(mp_int *a, ...);
|
||||
/* 24 */
|
||||
@@ -217,8 +216,7 @@ EXTERN int TclBN_mp_neg(const mp_int *a, mp_int *b);
|
||||
/* 34 */
|
||||
EXTERN int TclBN_mp_or(mp_int *a, mp_int *b, mp_int *c);
|
||||
/* 35 */
|
||||
EXTERN int TclBN_mp_radix_size(const mp_int *a, int radix,
|
||||
int *size);
|
||||
EXTERN int TclBN_mp_radix_size(mp_int *a, int radix, int *size);
|
||||
/* 36 */
|
||||
EXTERN int TclBN_mp_read_radix(mp_int *a, const char *str,
|
||||
int radix);
|
||||
@@ -289,9 +287,6 @@ EXTERN void TclBNInitBignumFromWideInt(mp_int *bignum,
|
||||
/* 66 */
|
||||
EXTERN void TclBNInitBignumFromWideUInt(mp_int *bignum,
|
||||
Tcl_WideUInt initVal);
|
||||
/* 67 */
|
||||
EXTERN int TclBN_mp_expt_d_ex(mp_int *a, mp_digit b, mp_int *c,
|
||||
int fast);
|
||||
|
||||
typedef struct TclTomMathStubs {
|
||||
int magic;
|
||||
@@ -319,7 +314,7 @@ typedef struct TclTomMathStubs {
|
||||
int (*tclBN_mp_expt_d) (mp_int *a, mp_digit b, mp_int *c); /* 19 */
|
||||
int (*tclBN_mp_grow) (mp_int *a, int size); /* 20 */
|
||||
int (*tclBN_mp_init) (mp_int *a); /* 21 */
|
||||
int (*tclBN_mp_init_copy) (mp_int *a, const mp_int *b); /* 22 */
|
||||
int (*tclBN_mp_init_copy) (mp_int *a, mp_int *b); /* 22 */
|
||||
int (*tclBN_mp_init_multi) (mp_int *a, ...); /* 23 */
|
||||
int (*tclBN_mp_init_set) (mp_int *a, mp_digit b); /* 24 */
|
||||
int (*tclBN_mp_init_size) (mp_int *a, int size); /* 25 */
|
||||
@@ -332,7 +327,7 @@ typedef struct TclTomMathStubs {
|
||||
int (*tclBN_mp_mul_2d) (const mp_int *a, int d, mp_int *p); /* 32 */
|
||||
int (*tclBN_mp_neg) (const mp_int *a, mp_int *b); /* 33 */
|
||||
int (*tclBN_mp_or) (mp_int *a, mp_int *b, mp_int *c); /* 34 */
|
||||
int (*tclBN_mp_radix_size) (const mp_int *a, int radix, int *size); /* 35 */
|
||||
int (*tclBN_mp_radix_size) (mp_int *a, int radix, int *size); /* 35 */
|
||||
int (*tclBN_mp_read_radix) (mp_int *a, const char *str, int radix); /* 36 */
|
||||
void (*tclBN_mp_rshd) (mp_int *a, int shift); /* 37 */
|
||||
int (*tclBN_mp_shrink) (mp_int *a); /* 38 */
|
||||
@@ -364,7 +359,6 @@ typedef struct TclTomMathStubs {
|
||||
void (*tclBNInitBignumFromLong) (mp_int *bignum, long initVal); /* 64 */
|
||||
void (*tclBNInitBignumFromWideInt) (mp_int *bignum, Tcl_WideInt initVal); /* 65 */
|
||||
void (*tclBNInitBignumFromWideUInt) (mp_int *bignum, Tcl_WideUInt initVal); /* 66 */
|
||||
int (*tclBN_mp_expt_d_ex) (mp_int *a, mp_digit b, mp_int *c, int fast); /* 67 */
|
||||
} TclTomMathStubs;
|
||||
|
||||
extern const TclTomMathStubs *tclTomMathStubsPtr;
|
||||
@@ -513,8 +507,6 @@ extern const TclTomMathStubs *tclTomMathStubsPtr;
|
||||
(tclTomMathStubsPtr->tclBNInitBignumFromWideInt) /* 65 */
|
||||
#define TclBNInitBignumFromWideUInt \
|
||||
(tclTomMathStubsPtr->tclBNInitBignumFromWideUInt) /* 66 */
|
||||
#define TclBN_mp_expt_d_ex \
|
||||
(tclTomMathStubsPtr->tclBN_mp_expt_d_ex) /* 67 */
|
||||
|
||||
#endif /* defined(USE_TCL_STUBS) */
|
||||
|
||||
|
||||
+1
-1
@@ -52,7 +52,7 @@ typedef struct {
|
||||
* invoked step trace */
|
||||
int curFlags; /* Trace flags for the current command */
|
||||
int curCode; /* Return code for the current command */
|
||||
size_t refCount; /* Used to ensure this structure is not
|
||||
int refCount; /* Used to ensure this structure is not
|
||||
* deleted too early. Keeps track of how many
|
||||
* pieces of code have a pointer to this
|
||||
* structure. */
|
||||
|
||||
+43
-23
@@ -73,7 +73,16 @@ static const unsigned char totalBytes[256] = {
|
||||
#else
|
||||
1,1,1,1,1,1,1,1,
|
||||
#endif
|
||||
1,1,1,1,1,1,1,1
|
||||
#if TCL_UTF_MAX > 4
|
||||
5,5,5,5,
|
||||
#else
|
||||
1,1,1,1,
|
||||
#endif
|
||||
#if TCL_UTF_MAX > 5
|
||||
6,6,6,6
|
||||
#else
|
||||
1,1,1,1
|
||||
#endif
|
||||
};
|
||||
|
||||
/*
|
||||
@@ -96,14 +105,14 @@ int
|
||||
TclUtfCount(
|
||||
int ch) /* The Tcl_UniChar whose size is returned. */
|
||||
{
|
||||
if ((unsigned)(ch - 1) < (UNICODE_SELF - 1)) {
|
||||
if ((ch > 0) && (ch < UNICODE_SELF)) {
|
||||
return 1;
|
||||
}
|
||||
if (ch <= 0x7FF) {
|
||||
return 2;
|
||||
}
|
||||
#if TCL_UTF_MAX > 3
|
||||
if (((unsigned)(ch - 0x10000) <= 0xfffff)) {
|
||||
if ((ch > 0xFFFF) && (ch <= 0x10FFFF)) {
|
||||
return 4;
|
||||
}
|
||||
#endif
|
||||
@@ -137,7 +146,7 @@ Tcl_UniCharToUtf(
|
||||
* large enough to hold the UTF-8 character
|
||||
* (at most TCL_UTF_MAX bytes). */
|
||||
{
|
||||
if ((unsigned)(ch - 1) < (UNICODE_SELF - 1)) {
|
||||
if ((ch > 0) && (ch < UNICODE_SELF)) {
|
||||
buf[0] = (char) ch;
|
||||
return 1;
|
||||
}
|
||||
@@ -165,7 +174,11 @@ Tcl_UniCharToUtf(
|
||||
}
|
||||
}
|
||||
#endif
|
||||
goto three;
|
||||
three:
|
||||
buf[2] = (char) ((ch | 0x80) & 0xBF);
|
||||
buf[1] = (char) (((ch >> 6) | 0x80) & 0xBF);
|
||||
buf[0] = (char) ((ch >> 12) | 0xE0);
|
||||
return 3;
|
||||
}
|
||||
|
||||
#if TCL_UTF_MAX > 3
|
||||
@@ -180,11 +193,7 @@ Tcl_UniCharToUtf(
|
||||
}
|
||||
|
||||
ch = 0xFFFD;
|
||||
three:
|
||||
buf[2] = (char) ((ch | 0x80) & 0xBF);
|
||||
buf[1] = (char) (((ch >> 6) | 0x80) & 0xBF);
|
||||
buf[0] = (char) ((ch >> 12) | 0xE0);
|
||||
return 3;
|
||||
goto three;
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -299,6 +308,9 @@ Tcl_UtfToUniChar(
|
||||
* A two-byte-character lead-byte not followed by trail-byte
|
||||
* represents itself.
|
||||
*/
|
||||
|
||||
*chPtr = (Tcl_UniChar) byte;
|
||||
return 1;
|
||||
} else if (byte < 0xF0) {
|
||||
if (((src[1] & 0xC0) == 0x80) && ((src[2] & 0xC0) == 0x80)) {
|
||||
/*
|
||||
@@ -314,23 +326,31 @@ Tcl_UtfToUniChar(
|
||||
* A three-byte-character lead-byte not followed by two trail-bytes
|
||||
* represents itself.
|
||||
*/
|
||||
|
||||
*chPtr = (Tcl_UniChar) byte;
|
||||
return 1;
|
||||
}
|
||||
#if TCL_UTF_MAX > 3
|
||||
else if (byte < 0xF8) {
|
||||
if (((src[1] & 0xC0) == 0x80) && ((src[2] & 0xC0) == 0x80) && ((src[3] & 0xC0) == 0x80)) {
|
||||
/*
|
||||
* Four-byte-character lead byte followed by three trail bytes.
|
||||
*/
|
||||
{
|
||||
int ch, total, trail;
|
||||
|
||||
*chPtr = (Tcl_UniChar) (((byte & 0x0E) << 18) | ((src[1] & 0x3F) << 12)
|
||||
| ((src[2] & 0x3F) << 6) | (src[3] & 0x3F));
|
||||
return 4;
|
||||
total = totalBytes[byte];
|
||||
trail = total - 1;
|
||||
if (trail > 0) {
|
||||
ch = byte & (0x3F >> trail);
|
||||
do {
|
||||
src++;
|
||||
if ((*src & 0xC0) != 0x80) {
|
||||
*chPtr = byte;
|
||||
return 1;
|
||||
}
|
||||
ch <<= 6;
|
||||
ch |= (*src & 0x3F);
|
||||
trail--;
|
||||
} while (trail > 0);
|
||||
*chPtr = ch;
|
||||
return total;
|
||||
}
|
||||
|
||||
/*
|
||||
* A three-byte-character lead-byte not followed by two trail-bytes
|
||||
* represents itself.
|
||||
*/
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
+14
-13
@@ -2953,7 +2953,7 @@ Tcl_DStringGetResult(
|
||||
dsPtr->length = 0;
|
||||
dsPtr->spaceAvl = TCL_DSTRING_STATIC_SIZE;
|
||||
} else {
|
||||
dsPtr->string = TclGetString(iPtr->objResultPtr);
|
||||
dsPtr->string = Tcl_GetString(iPtr->objResultPtr);
|
||||
dsPtr->length = iPtr->objResultPtr->length;
|
||||
dsPtr->spaceAvl = dsPtr->length + 1;
|
||||
TclFreeIntRep(iPtr->objResultPtr);
|
||||
@@ -3639,7 +3639,7 @@ TclGetIntForIndex(
|
||||
|
||||
parseError:
|
||||
if (interp != NULL) {
|
||||
bytes = TclGetString(objPtr);
|
||||
bytes = Tcl_GetString(objPtr);
|
||||
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
|
||||
"bad index \"%s\": must be integer?[+-]integer? or"
|
||||
" end?[+-]integer?", bytes));
|
||||
@@ -4000,10 +4000,9 @@ TclSetProcessGlobalValue(
|
||||
} else {
|
||||
Tcl_CreateExitHandler(FreeProcessGlobalValue, pgvPtr);
|
||||
}
|
||||
bytes = TclGetString(newValue);
|
||||
pgvPtr->numBytes = newValue->length;
|
||||
bytes = TclGetStringFromObj(newValue, &pgvPtr->numBytes);
|
||||
pgvPtr->value = ckalloc(pgvPtr->numBytes + 1);
|
||||
memcpy(pgvPtr->value, bytes, pgvPtr->numBytes + 1);
|
||||
memcpy(pgvPtr->value, bytes, (unsigned) pgvPtr->numBytes + 1);
|
||||
if (pgvPtr->encoding) {
|
||||
Tcl_FreeEncoding(pgvPtr->encoding);
|
||||
}
|
||||
@@ -4018,7 +4017,7 @@ TclSetProcessGlobalValue(
|
||||
Tcl_IncrRefCount(newValue);
|
||||
cacheMap = GetThreadHash(&pgvPtr->key);
|
||||
ClearHash(cacheMap);
|
||||
hPtr = Tcl_CreateHashEntry(cacheMap, (void *)(pgvPtr->epoch), &dummy);
|
||||
hPtr = Tcl_CreateHashEntry(cacheMap, INT2PTR(pgvPtr->epoch), &dummy);
|
||||
Tcl_SetHashValue(hPtr, newValue);
|
||||
Tcl_MutexUnlock(&pgvPtr->mutex);
|
||||
}
|
||||
@@ -4044,7 +4043,7 @@ TclGetProcessGlobalValue(
|
||||
Tcl_Obj *value = NULL;
|
||||
Tcl_HashTable *cacheMap;
|
||||
Tcl_HashEntry *hPtr;
|
||||
size_t epoch = pgvPtr->epoch;
|
||||
int epoch = pgvPtr->epoch;
|
||||
|
||||
if (pgvPtr->encoding) {
|
||||
Tcl_Encoding current = Tcl_GetEncoding(NULL, NULL);
|
||||
@@ -4059,7 +4058,8 @@ TclGetProcessGlobalValue(
|
||||
Tcl_DString native, newValue;
|
||||
|
||||
Tcl_MutexLock(&pgvPtr->mutex);
|
||||
epoch = ++pgvPtr->epoch;
|
||||
pgvPtr->epoch++;
|
||||
epoch = pgvPtr->epoch;
|
||||
Tcl_UtfToExternalDString(pgvPtr->encoding, pgvPtr->value,
|
||||
pgvPtr->numBytes, &native);
|
||||
Tcl_ExternalToUtfDString(current, Tcl_DStringValue(&native),
|
||||
@@ -4078,7 +4078,7 @@ TclGetProcessGlobalValue(
|
||||
}
|
||||
}
|
||||
cacheMap = GetThreadHash(&pgvPtr->key);
|
||||
hPtr = Tcl_FindHashEntry(cacheMap, (void *) (epoch));
|
||||
hPtr = Tcl_FindHashEntry(cacheMap, (char *) INT2PTR(epoch));
|
||||
if (NULL == hPtr) {
|
||||
int dummy;
|
||||
|
||||
@@ -4111,7 +4111,7 @@ TclGetProcessGlobalValue(
|
||||
|
||||
value = Tcl_NewStringObj(pgvPtr->value, pgvPtr->numBytes);
|
||||
hPtr = Tcl_CreateHashEntry(cacheMap,
|
||||
(void *)(pgvPtr->epoch), &dummy);
|
||||
INT2PTR(pgvPtr->epoch), &dummy);
|
||||
Tcl_MutexUnlock(&pgvPtr->mutex);
|
||||
Tcl_SetHashValue(hPtr, value);
|
||||
Tcl_IncrRefCount(value);
|
||||
@@ -4194,10 +4194,11 @@ TclGetObjNameOfExecutable(void)
|
||||
const char *
|
||||
Tcl_GetNameOfExecutable(void)
|
||||
{
|
||||
Tcl_Obj *obj = TclGetObjNameOfExecutable();
|
||||
const char *bytes = TclGetString(obj);
|
||||
int numBytes;
|
||||
const char *bytes =
|
||||
Tcl_GetStringFromObj(TclGetObjNameOfExecutable(), &numBytes);
|
||||
|
||||
if (obj->length == 0) {
|
||||
if (numBytes == 0) {
|
||||
return NULL;
|
||||
}
|
||||
return bytes;
|
||||
|
||||
+8
-22
@@ -2754,7 +2754,7 @@ TclArraySet(
|
||||
} else {
|
||||
/*
|
||||
* Not a dictionary, so assume (and convert to, for backward-
|
||||
* -compatibility reasons) a list.
|
||||
* -compatability reasons) a list.
|
||||
*/
|
||||
|
||||
int elemLen;
|
||||
@@ -2983,7 +2983,7 @@ ArrayAnyMoreCmd(
|
||||
if (varPtr == NULL) {
|
||||
return TCL_ERROR;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Get the search.
|
||||
*/
|
||||
@@ -3056,7 +3056,7 @@ ArrayNextElementCmd(
|
||||
varPtr = VerifyArray(interp, varNameObj);
|
||||
if (varPtr == NULL) {
|
||||
return TCL_ERROR;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Get the search.
|
||||
@@ -4956,16 +4956,13 @@ TclDeleteNamespaceVars(
|
||||
VarHashRefCount(varPtr)++; /* Make sure we get to remove from
|
||||
* hash. */
|
||||
Tcl_GetVariableFullName(interp, (Tcl_Var) varPtr, objPtr);
|
||||
UnsetVarStruct(varPtr, NULL, iPtr, /* part1 */ objPtr,
|
||||
NULL, flags, -1);
|
||||
UnsetVarStruct(varPtr, NULL, iPtr, /* part1 */ objPtr, NULL, flags,
|
||||
-1);
|
||||
Tcl_DecrRefCount(objPtr); /* Free no longer needed obj */
|
||||
|
||||
/*
|
||||
* We just unset the variable. However, an unset trace might
|
||||
* have re-set it, or might have re-established traces on it.
|
||||
* This namespace and its vartable are going away unconditionally,
|
||||
* so we cannot let such things linger. That would be a leak.
|
||||
*
|
||||
* First we destroy all traces. ...
|
||||
* Remove the variable from the table and force it undefined in case
|
||||
* an unset trace brought it back from the dead.
|
||||
*/
|
||||
|
||||
if (TclIsVarTraced(varPtr)) {
|
||||
@@ -4989,17 +4986,6 @@ TclDeleteNamespaceVars(
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* ...and then, if the variable still holds a value, we unset it
|
||||
* again. This time with no traces left, we're sure it goes away.
|
||||
*/
|
||||
|
||||
if (!TclIsVarUndefined(varPtr)) {
|
||||
UnsetVarStruct(varPtr, NULL, iPtr, /* part1 */ objPtr,
|
||||
NULL, flags, -1);
|
||||
}
|
||||
Tcl_DecrRefCount(objPtr); /* free no longer needed obj */
|
||||
VarHashRefCount(varPtr)--;
|
||||
VarHashDeleteEntry(varPtr);
|
||||
}
|
||||
|
||||
+75
-118
@@ -177,8 +177,6 @@ static Tcl_ObjCmdProc ZlibStreamPutCmd;
|
||||
static void ConvertError(Tcl_Interp *interp, int code,
|
||||
uLong adler);
|
||||
static Tcl_Obj * ConvertErrorToList(int code, uLong adler);
|
||||
static inline int Deflate(z_streamp strm, void *bufferPtr,
|
||||
int bufferSize, int flush, int *writtenPtr);
|
||||
static void ExtractHeader(gz_header *headerPtr, Tcl_Obj *dictObj);
|
||||
static int GenerateHeader(Tcl_Interp *interp, Tcl_Obj *dictObj,
|
||||
GzipHeader *headerPtr, int *extraSizePtr);
|
||||
@@ -373,7 +371,7 @@ ConvertErrorToList(
|
||||
|
||||
default:
|
||||
TclNewLiteralStringObj(objv[2], "UNKNOWN");
|
||||
TclNewLongObj(objv[3], code);
|
||||
TclNewIntObj(objv[3], code);
|
||||
return Tcl_NewListObj(4, objv);
|
||||
}
|
||||
}
|
||||
@@ -580,10 +578,6 @@ ExtractHeader(
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Disentangle the worst of how the zlib API is used.
|
||||
*/
|
||||
|
||||
static int
|
||||
SetInflateDictionary(
|
||||
z_streamp strm,
|
||||
@@ -611,38 +605,6 @@ SetDeflateDictionary(
|
||||
}
|
||||
return Z_OK;
|
||||
}
|
||||
|
||||
static inline int
|
||||
Deflate(
|
||||
z_streamp strm,
|
||||
void *bufferPtr,
|
||||
int bufferSize,
|
||||
int flush,
|
||||
int *writtenPtr)
|
||||
{
|
||||
int e;
|
||||
|
||||
strm->next_out = (Bytef *) bufferPtr;
|
||||
strm->avail_out = (unsigned) bufferSize;
|
||||
e = deflate(strm, flush);
|
||||
if (writtenPtr != NULL) {
|
||||
*writtenPtr = bufferSize - strm->avail_out;
|
||||
}
|
||||
return e;
|
||||
}
|
||||
|
||||
static inline void
|
||||
AppendByteArray(
|
||||
Tcl_Obj *listObj,
|
||||
void *buffer,
|
||||
int size)
|
||||
{
|
||||
if (size > 0) {
|
||||
Tcl_Obj *baObj = Tcl_NewByteArrayObj((unsigned char *) buffer, size);
|
||||
|
||||
Tcl_ListObjAppendElement(NULL, listObj, baObj);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
*----------------------------------------------------------------------
|
||||
@@ -1177,8 +1139,6 @@ Tcl_ZlibStreamSetCompressionDictionary(
|
||||
*----------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
#define BUFFER_SIZE_LIMIT 0xFFFF
|
||||
|
||||
int
|
||||
Tcl_ZlibStreamPut(
|
||||
Tcl_ZlibStream zshandle, /* As obtained from Tcl_ZlibStreamInit */
|
||||
@@ -1188,7 +1148,8 @@ Tcl_ZlibStreamPut(
|
||||
{
|
||||
ZlibStreamHandle *zshPtr = (ZlibStreamHandle *) zshandle;
|
||||
char *dataTmp = NULL;
|
||||
int e, size, outSize, toStore;
|
||||
int e, size, outSize;
|
||||
Tcl_Obj *obj;
|
||||
|
||||
if (zshPtr->streamEnd) {
|
||||
if (zshPtr->interp) {
|
||||
@@ -1214,45 +1175,26 @@ Tcl_ZlibStreamPut(
|
||||
if (HaveDictToSet(zshPtr)) {
|
||||
e = SetDeflateDictionary(&zshPtr->stream, zshPtr->compDictObj);
|
||||
if (e != Z_OK) {
|
||||
ConvertError(zshPtr->interp, e, zshPtr->stream.adler);
|
||||
if (zshPtr->interp) {
|
||||
ConvertError(zshPtr->interp, e, zshPtr->stream.adler);
|
||||
}
|
||||
return TCL_ERROR;
|
||||
}
|
||||
DictWasSet(zshPtr);
|
||||
}
|
||||
|
||||
/*
|
||||
* deflateBound() doesn't seem to take various header sizes into
|
||||
* account, so we add 100 extra bytes. However, we can also loop
|
||||
* around again so we also set an upper bound on the output buffer
|
||||
* size.
|
||||
* Deflatebound doesn't seem to take various header sizes into
|
||||
* account, so we add 100 extra bytes.
|
||||
*/
|
||||
|
||||
outSize = deflateBound(&zshPtr->stream, size) + 100;
|
||||
if (outSize > BUFFER_SIZE_LIMIT) {
|
||||
outSize = BUFFER_SIZE_LIMIT;
|
||||
}
|
||||
dataTmp = ckalloc(outSize);
|
||||
|
||||
while (1) {
|
||||
e = Deflate(&zshPtr->stream, dataTmp, outSize, flush, &toStore);
|
||||
|
||||
/*
|
||||
* Test if we've filled the buffer up and have to ask deflate() to
|
||||
* give us some more. Note that the condition for needing to
|
||||
* repeat a buffer transfer when the result is Z_OK is whether
|
||||
* there is no more space in the buffer we provided; the zlib
|
||||
* library does not necessarily return a different code in that
|
||||
* case. [Bug b26e38a3e4] [Tk Bug 10f2e7872b]
|
||||
*/
|
||||
|
||||
if ((e != Z_BUF_ERROR) && (e != Z_OK || toStore < outSize)) {
|
||||
if ((e == Z_OK) || (flush == Z_FINISH && e == Z_STREAM_END)) {
|
||||
break;
|
||||
}
|
||||
ConvertError(zshPtr->interp, e, zshPtr->stream.adler);
|
||||
return TCL_ERROR;
|
||||
}
|
||||
outSize = deflateBound(&zshPtr->stream, zshPtr->stream.avail_in)+100;
|
||||
zshPtr->stream.avail_out = outSize;
|
||||
dataTmp = ckalloc(zshPtr->stream.avail_out);
|
||||
zshPtr->stream.next_out = (Bytef *) dataTmp;
|
||||
|
||||
e = deflate(&zshPtr->stream, flush);
|
||||
while (e == Z_BUF_ERROR || (flush == Z_FINISH && e == Z_OK)) {
|
||||
/*
|
||||
* Output buffer too small to hold the data being generated or we
|
||||
* are doing the end-of-stream flush (which can spit out masses of
|
||||
@@ -1260,21 +1202,45 @@ Tcl_ZlibStreamPut(
|
||||
* saving the old generated data to the outData list.
|
||||
*/
|
||||
|
||||
AppendByteArray(zshPtr->outData, dataTmp, outSize);
|
||||
obj = Tcl_NewByteArrayObj((unsigned char *) dataTmp, outSize);
|
||||
Tcl_ListObjAppendElement(NULL, zshPtr->outData, obj);
|
||||
|
||||
if (outSize < BUFFER_SIZE_LIMIT) {
|
||||
outSize = BUFFER_SIZE_LIMIT;
|
||||
/* There may be *lots* of data left to output... */
|
||||
if (outSize < 0xFFFF) {
|
||||
outSize = 0xFFFF; /* There may be *lots* of data left to
|
||||
* output... */
|
||||
dataTmp = ckrealloc(dataTmp, outSize);
|
||||
}
|
||||
zshPtr->stream.avail_out = outSize;
|
||||
zshPtr->stream.next_out = (Bytef *) dataTmp;
|
||||
|
||||
e = deflate(&zshPtr->stream, flush);
|
||||
}
|
||||
|
||||
if (e != Z_OK && !(flush==Z_FINISH && e==Z_STREAM_END)) {
|
||||
if (zshPtr->interp) {
|
||||
ConvertError(zshPtr->interp, e, zshPtr->stream.adler);
|
||||
}
|
||||
return TCL_ERROR;
|
||||
}
|
||||
|
||||
/*
|
||||
* And append the final data block to the outData list.
|
||||
* And append the final data block.
|
||||
*/
|
||||
|
||||
AppendByteArray(zshPtr->outData, dataTmp, toStore);
|
||||
ckfree(dataTmp);
|
||||
if (outSize - zshPtr->stream.avail_out > 0) {
|
||||
obj = Tcl_NewByteArrayObj((unsigned char *) dataTmp,
|
||||
outSize - zshPtr->stream.avail_out);
|
||||
|
||||
/*
|
||||
* Now append the compressed data to the outData list.
|
||||
*/
|
||||
|
||||
Tcl_ListObjAppendElement(NULL, zshPtr->outData, obj);
|
||||
}
|
||||
|
||||
if (dataTmp) {
|
||||
ckfree(dataTmp);
|
||||
}
|
||||
} else {
|
||||
/*
|
||||
* This is easy. Just append to the inData list.
|
||||
@@ -1390,7 +1356,9 @@ Tcl_ZlibStreamGet(
|
||||
if (IsRawStream(zshPtr) && HaveDictToSet(zshPtr)) {
|
||||
e = SetInflateDictionary(&zshPtr->stream, zshPtr->compDictObj);
|
||||
if (e != Z_OK) {
|
||||
ConvertError(zshPtr->interp, e, zshPtr->stream.adler);
|
||||
if (zshPtr->interp) {
|
||||
ConvertError(zshPtr->interp, e, zshPtr->stream.adler);
|
||||
}
|
||||
return TCL_ERROR;
|
||||
}
|
||||
DictWasSet(zshPtr);
|
||||
@@ -2896,7 +2864,7 @@ ZlibTransformClose(
|
||||
Tcl_Interp *interp)
|
||||
{
|
||||
ZlibChannelData *cd = instanceData;
|
||||
int e, written, result = TCL_OK;
|
||||
int e, result = TCL_OK;
|
||||
|
||||
/*
|
||||
* Delete the support timer.
|
||||
@@ -2911,18 +2879,9 @@ ZlibTransformClose(
|
||||
if (cd->mode == TCL_ZLIB_STREAM_DEFLATE) {
|
||||
cd->outStream.avail_in = 0;
|
||||
do {
|
||||
e = Deflate(&cd->outStream, cd->outBuffer, cd->outAllocated,
|
||||
Z_FINISH, &written);
|
||||
|
||||
/*
|
||||
* Can't be sure that deflate() won't declare the buffer to be
|
||||
* full (with Z_BUF_ERROR) so handle that case.
|
||||
*/
|
||||
|
||||
if (e == Z_BUF_ERROR) {
|
||||
e = Z_OK;
|
||||
written = cd->outAllocated;
|
||||
}
|
||||
cd->outStream.next_out = (Bytef *) cd->outBuffer;
|
||||
cd->outStream.avail_out = (unsigned) cd->outAllocated;
|
||||
e = deflate(&cd->outStream, Z_FINISH);
|
||||
if (e != Z_OK && e != Z_STREAM_END) {
|
||||
/* TODO: is this the right way to do errors on close? */
|
||||
if (!TclInThreadExit()) {
|
||||
@@ -2931,17 +2890,20 @@ ZlibTransformClose(
|
||||
result = TCL_ERROR;
|
||||
break;
|
||||
}
|
||||
if (written && Tcl_WriteRaw(cd->parent, cd->outBuffer, written) < 0) {
|
||||
/* TODO: is this the right way to do errors on close?
|
||||
* Note: when close is called from FinalizeIOSubsystem then
|
||||
* interp may be NULL */
|
||||
if (!TclInThreadExit() && interp) {
|
||||
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
|
||||
"error while finalizing file: %s",
|
||||
Tcl_PosixError(interp)));
|
||||
if (cd->outStream.avail_out != (unsigned) cd->outAllocated) {
|
||||
if (Tcl_WriteRaw(cd->parent, cd->outBuffer,
|
||||
cd->outAllocated - cd->outStream.avail_out) < 0) {
|
||||
/* TODO: is this the right way to do errors on close?
|
||||
* Note: when close is called from FinalizeIOSubsystem
|
||||
* then interp may be NULL */
|
||||
if (!TclInThreadExit() && interp) {
|
||||
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
|
||||
"error while finalizing file: %s",
|
||||
Tcl_PosixError(interp)));
|
||||
}
|
||||
result = TCL_ERROR;
|
||||
break;
|
||||
}
|
||||
result = TCL_ERROR;
|
||||
break;
|
||||
}
|
||||
} while (e != Z_STREAM_END);
|
||||
(void) deflateEnd(&cd->outStream);
|
||||
@@ -3116,21 +3078,13 @@ ZlibTransformOutput(
|
||||
cd->outStream.next_in = (Bytef *) buf;
|
||||
cd->outStream.avail_in = toWrite;
|
||||
do {
|
||||
e = Deflate(&cd->outStream, cd->outBuffer, cd->outAllocated,
|
||||
Z_NO_FLUSH, &produced);
|
||||
cd->outStream.next_out = (Bytef *) cd->outBuffer;
|
||||
cd->outStream.avail_out = cd->outAllocated;
|
||||
|
||||
if ((e == Z_OK && produced > 0) || e == Z_BUF_ERROR) {
|
||||
/*
|
||||
* deflate() indicates that it is out of space by returning
|
||||
* Z_BUF_ERROR *or* by simply returning Z_OK with no remaining
|
||||
* space; in either case, we must write the whole buffer out and
|
||||
* retry to compress what is left.
|
||||
*/
|
||||
e = deflate(&cd->outStream, Z_NO_FLUSH);
|
||||
produced = cd->outAllocated - cd->outStream.avail_out;
|
||||
|
||||
if (e == Z_BUF_ERROR) {
|
||||
produced = cd->outAllocated;
|
||||
e = Z_OK;
|
||||
}
|
||||
if (e == Z_OK && produced > 0) {
|
||||
if (Tcl_WriteRaw(cd->parent, cd->outBuffer, produced) < 0) {
|
||||
*errorCodePtr = Tcl_GetErrno();
|
||||
return -1;
|
||||
@@ -3177,8 +3131,10 @@ ZlibTransformFlush(
|
||||
* Get the bytes to go out of the compression engine.
|
||||
*/
|
||||
|
||||
e = Deflate(&cd->outStream, cd->outBuffer, cd->outAllocated,
|
||||
flushType, &len);
|
||||
cd->outStream.next_out = (Bytef *) cd->outBuffer;
|
||||
cd->outStream.avail_out = cd->outAllocated;
|
||||
|
||||
e = deflate(&cd->outStream, flushType);
|
||||
if (e != Z_OK && e != Z_BUF_ERROR) {
|
||||
ConvertError(interp, e, cd->outStream.adler);
|
||||
return TCL_ERROR;
|
||||
@@ -3188,6 +3144,7 @@ ZlibTransformFlush(
|
||||
* Write the bytes we've received to the next layer.
|
||||
*/
|
||||
|
||||
len = cd->outStream.next_out - (Bytef *) cd->outBuffer;
|
||||
if (len > 0 && Tcl_WriteRaw(cd->parent, cd->outBuffer, len) < 0) {
|
||||
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
|
||||
"problem flushing channel: %s",
|
||||
|
||||
+8
-3
@@ -122,9 +122,11 @@ proc tcl_findLibrary {basename version patch initScript enVarName varName} {
|
||||
# uniquify $dirs in order
|
||||
array set seen {}
|
||||
foreach i $dirs {
|
||||
# Make sure $i is unique under normalization. Avoid repeated [source].
|
||||
# Take note that the [file normalize] below has been noted to cause
|
||||
# difficulties for the freewrap utility. See Bug 1072136. Until
|
||||
# freewrap resolves the matter, one might work around the problem by
|
||||
# disabling that branch.
|
||||
if {[interp issafe]} {
|
||||
# Safe interps have no [file normalize].
|
||||
set norm $i
|
||||
} else {
|
||||
set norm [file normalize $i]
|
||||
@@ -133,7 +135,10 @@ proc tcl_findLibrary {basename version patch initScript enVarName varName} {
|
||||
continue
|
||||
}
|
||||
set seen($norm) {}
|
||||
|
||||
lappend uniqdirs $i
|
||||
}
|
||||
set dirs $uniqdirs
|
||||
foreach i $dirs {
|
||||
set the_library $i
|
||||
set file [file join $i $initScript]
|
||||
|
||||
|
||||
@@ -56,30 +56,6 @@ proc ::history {args} {
|
||||
tailcall apply {arglist {tailcall history {*}$arglist} ::tcl} $args
|
||||
}
|
||||
|
||||
# (unnamed) --
|
||||
#
|
||||
# Callback when [::history] is destroyed. Destroys the implementation.
|
||||
#
|
||||
# Parameters:
|
||||
# oldName what the command was called.
|
||||
# newName what the command is now called (an empty string).
|
||||
# op the operation (= delete).
|
||||
#
|
||||
# Results:
|
||||
# none
|
||||
#
|
||||
# Side Effects:
|
||||
# The implementation of the [::history] command ceases to exist.
|
||||
|
||||
trace add command ::history delete [list apply {{oldName newName op} {
|
||||
variable history
|
||||
unset -nocomplain history
|
||||
foreach c [info procs ::tcl::Hist*] {
|
||||
rename $c {}
|
||||
}
|
||||
rename ::tcl::history {}
|
||||
} ::tcl}]
|
||||
|
||||
# tcl::HistAdd --
|
||||
#
|
||||
# Add an item to the history, and optionally eval it at the global scope
|
||||
|
||||
+4
-36
@@ -8,10 +8,10 @@
|
||||
# See the file "license.terms" for information on usage and redistribution of
|
||||
# this file, and for a DISCLAIMER OF ALL WARRANTIES.
|
||||
|
||||
package require Tcl 8.6-
|
||||
package require Tcl 8.6
|
||||
# Keep this in sync with pkgIndex.tcl and with the install directories in
|
||||
# Makefiles
|
||||
package provide http 2.8.10
|
||||
package provide http 2.8.9
|
||||
|
||||
namespace eval http {
|
||||
# Allow resourcing to not clobber existing data
|
||||
@@ -1047,7 +1047,7 @@ proc http::Event {sock token} {
|
||||
fconfigure $sock -translation binary
|
||||
|
||||
if {
|
||||
$state(-binary) || [IsBinaryContentType $state(type)]
|
||||
$state(-binary) || ![string match -nocase text* $state(type)]
|
||||
} {
|
||||
# Turn off conversions for non-text data
|
||||
set state(binary) 1
|
||||
@@ -1183,38 +1183,6 @@ proc http::Event {sock token} {
|
||||
}
|
||||
}
|
||||
|
||||
# http::IsBinaryContentType --
|
||||
#
|
||||
# Determine if the content-type means that we should definitely transfer
|
||||
# the data as binary. [Bug 838e99a76d]
|
||||
#
|
||||
# Arguments
|
||||
# type The content-type of the data.
|
||||
#
|
||||
# Results:
|
||||
# Boolean, true if we definitely should be binary.
|
||||
|
||||
proc http::IsBinaryContentType {type} {
|
||||
lassign [split [string tolower $type] "/;"] major minor
|
||||
if {$major eq "text"} {
|
||||
return false
|
||||
}
|
||||
# There's a bunch of XML-as-application-format things about. See RFC 3023
|
||||
# and so on.
|
||||
if {$major eq "application"} {
|
||||
set minor [string trimright $minor]
|
||||
if {$minor in {"xml" "xml-external-parsed-entity" "xml-dtd"}} {
|
||||
return false
|
||||
}
|
||||
}
|
||||
# Not just application/foobar+xml but also image/svg+xml, so let us not
|
||||
# restrict things for now...
|
||||
if {[string match "*+xml" $minor]} {
|
||||
return false
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
# http::getTextLine --
|
||||
#
|
||||
# Get one line with the stream in blocking crlf mode
|
||||
@@ -1447,7 +1415,7 @@ proc http::mapReply {string} {
|
||||
set converted [string map $formMap $string]
|
||||
if {[string match "*\[\u0100-\uffff\]*" $converted]} {
|
||||
regexp "\[\u0100-\uffff\]" $converted badChar
|
||||
# Return this error message for maximum compatibility... :^/
|
||||
# Return this error message for maximum compatability... :^/
|
||||
return -code error \
|
||||
"can't read \"formMap($badChar)\": no such element in array"
|
||||
}
|
||||
|
||||
@@ -1,2 +1,2 @@
|
||||
if {![package vsatisfies [package provide Tcl] 8.6-]} {return}
|
||||
package ifneeded http 2.8.10 [list tclPkgSetup $dir http 2.8.10 {{http.tcl source {::http::config ::http::formatQuery ::http::geturl ::http::reset ::http::wait ::http::register ::http::unregister ::http::mapReply}}}]
|
||||
if {![package vsatisfies [package provide Tcl] 8.6]} {return}
|
||||
package ifneeded http 2.8.9 [list tclPkgSetup $dir http 2.8.9 {{http.tcl source {::http::config ::http::formatQuery ::http::geturl ::http::reset ::http::wait ::http::register ::http::unregister ::http::mapReply}}}]
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
# See the file "license.terms" for information on usage and redistribution
|
||||
# of this file, and for a DISCLAIMER OF ALL WARRANTIES.
|
||||
|
||||
package require Tcl 8.5-
|
||||
package require Tcl 8.5
|
||||
# When the version number changes, be sure to update the pkgIndex.tcl file,
|
||||
# and the installation directory in the Makefiles.
|
||||
package provide msgcat 1.6.0
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
# Contributions from Don Porter, NIST, 2002. (not subject to US copyright)
|
||||
# All rights reserved.
|
||||
|
||||
package require Tcl 8.5- ;# -verbose line uses [info frame]
|
||||
package require Tcl 8.5 ;# -verbose line uses [info frame]
|
||||
namespace eval tcltest {
|
||||
|
||||
# When the version number changes, be sure to update the pkgIndex.tcl file,
|
||||
|
||||
@@ -11,41 +11,41 @@ set TZData(:America/Los_Angeles) {
|
||||
{-769395600 -25200 1 PPT}
|
||||
{-765385200 -28800 0 PST}
|
||||
{-757353600 -28800 0 PST}
|
||||
{-687967140 -25200 1 PDT}
|
||||
{-687967200 -25200 1 PDT}
|
||||
{-662655600 -28800 0 PST}
|
||||
{-620838000 -25200 1 PDT}
|
||||
{-620834400 -25200 1 PDT}
|
||||
{-608137200 -28800 0 PST}
|
||||
{-589388400 -25200 1 PDT}
|
||||
{-589384800 -25200 1 PDT}
|
||||
{-576082800 -28800 0 PST}
|
||||
{-557938800 -25200 1 PDT}
|
||||
{-557935200 -25200 1 PDT}
|
||||
{-544633200 -28800 0 PST}
|
||||
{-526489200 -25200 1 PDT}
|
||||
{-526485600 -25200 1 PDT}
|
||||
{-513183600 -28800 0 PST}
|
||||
{-495039600 -25200 1 PDT}
|
||||
{-495036000 -25200 1 PDT}
|
||||
{-481734000 -28800 0 PST}
|
||||
{-463590000 -25200 1 PDT}
|
||||
{-463586400 -25200 1 PDT}
|
||||
{-450284400 -28800 0 PST}
|
||||
{-431535600 -25200 1 PDT}
|
||||
{-431532000 -25200 1 PDT}
|
||||
{-418230000 -28800 0 PST}
|
||||
{-400086000 -25200 1 PDT}
|
||||
{-400082400 -25200 1 PDT}
|
||||
{-386780400 -28800 0 PST}
|
||||
{-368636400 -25200 1 PDT}
|
||||
{-368632800 -25200 1 PDT}
|
||||
{-355330800 -28800 0 PST}
|
||||
{-337186800 -25200 1 PDT}
|
||||
{-337183200 -25200 1 PDT}
|
||||
{-323881200 -28800 0 PST}
|
||||
{-305737200 -25200 1 PDT}
|
||||
{-305733600 -25200 1 PDT}
|
||||
{-292431600 -28800 0 PST}
|
||||
{-273682800 -25200 1 PDT}
|
||||
{-273679200 -25200 1 PDT}
|
||||
{-260982000 -28800 0 PST}
|
||||
{-242233200 -25200 1 PDT}
|
||||
{-242229600 -25200 1 PDT}
|
||||
{-226508400 -28800 0 PST}
|
||||
{-210783600 -25200 1 PDT}
|
||||
{-210780000 -25200 1 PDT}
|
||||
{-195058800 -28800 0 PST}
|
||||
{-179334000 -25200 1 PDT}
|
||||
{-179330400 -25200 1 PDT}
|
||||
{-163609200 -28800 0 PST}
|
||||
{-147884400 -25200 1 PDT}
|
||||
{-147880800 -25200 1 PDT}
|
||||
{-131554800 -28800 0 PST}
|
||||
{-116434800 -25200 1 PDT}
|
||||
{-116431200 -25200 1 PDT}
|
||||
{-100105200 -28800 0 PST}
|
||||
{-94665600 -28800 0 PST}
|
||||
{-84376800 -25200 1 PDT}
|
||||
|
||||
@@ -14,19 +14,19 @@ set TZData(:America/Tijuana) {
|
||||
{-686073600 -25200 1 PDT}
|
||||
{-661539600 -28800 0 PST}
|
||||
{-504892800 -28800 0 PST}
|
||||
{-495039600 -25200 1 PDT}
|
||||
{-495036000 -25200 1 PDT}
|
||||
{-481734000 -28800 0 PST}
|
||||
{-463590000 -25200 1 PDT}
|
||||
{-463586400 -25200 1 PDT}
|
||||
{-450284400 -28800 0 PST}
|
||||
{-431535600 -25200 1 PDT}
|
||||
{-431532000 -25200 1 PDT}
|
||||
{-418230000 -28800 0 PST}
|
||||
{-400086000 -25200 1 PDT}
|
||||
{-400082400 -25200 1 PDT}
|
||||
{-386780400 -28800 0 PST}
|
||||
{-368636400 -25200 1 PDT}
|
||||
{-368632800 -25200 1 PDT}
|
||||
{-355330800 -28800 0 PST}
|
||||
{-337186800 -25200 1 PDT}
|
||||
{-337183200 -25200 1 PDT}
|
||||
{-323881200 -28800 0 PST}
|
||||
{-305737200 -25200 1 PDT}
|
||||
{-305733600 -25200 1 PDT}
|
||||
{-292431600 -28800 0 PST}
|
||||
{-283968000 -28800 0 PST}
|
||||
{189331200 -28800 0 PST}
|
||||
|
||||
@@ -2,10 +2,9 @@
|
||||
|
||||
set TZData(:Antarctica/Casey) {
|
||||
{-9223372036854775808 0 0 -00}
|
||||
{-31536000 28800 0 +08}
|
||||
{1255802400 39600 0 +11}
|
||||
{1267714800 28800 0 +08}
|
||||
{1319738400 39600 0 +11}
|
||||
{1329843600 28800 0 +08}
|
||||
{1477065600 39600 0 +11}
|
||||
{-31536000 28800 0 AWST}
|
||||
{1255802400 39600 0 CAST}
|
||||
{1267714800 28800 0 AWST}
|
||||
{1319738400 39600 0 CAST}
|
||||
{1329843600 28800 0 AWST}
|
||||
}
|
||||
|
||||
@@ -2,11 +2,11 @@
|
||||
|
||||
set TZData(:Antarctica/Davis) {
|
||||
{-9223372036854775808 0 0 -00}
|
||||
{-409190400 25200 0 +07}
|
||||
{-409190400 25200 0 DAVT}
|
||||
{-163062000 0 0 -00}
|
||||
{-28857600 25200 0 +07}
|
||||
{1255806000 18000 0 +05}
|
||||
{1268251200 25200 0 +07}
|
||||
{1319742000 18000 0 +05}
|
||||
{1329854400 25200 0 +07}
|
||||
{-28857600 25200 0 DAVT}
|
||||
{1255806000 18000 0 DAVT}
|
||||
{1268251200 25200 0 DAVT}
|
||||
{1319742000 18000 0 DAVT}
|
||||
{1329854400 25200 0 DAVT}
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
set TZData(:Antarctica/DumontDUrville) {
|
||||
{-9223372036854775808 0 0 -00}
|
||||
{-725846400 36000 0 +10}
|
||||
{-725846400 36000 0 PMT}
|
||||
{-566992800 0 0 -00}
|
||||
{-415497600 36000 0 +10}
|
||||
{-415497600 36000 0 DDUT}
|
||||
}
|
||||
|
||||
@@ -2,6 +2,6 @@
|
||||
|
||||
set TZData(:Antarctica/Mawson) {
|
||||
{-9223372036854775808 0 0 -00}
|
||||
{-501206400 21600 0 +06}
|
||||
{1255809600 18000 0 +05}
|
||||
{-501206400 21600 0 MAWT}
|
||||
{1255809600 18000 0 MAWT}
|
||||
}
|
||||
|
||||
@@ -2,5 +2,5 @@
|
||||
|
||||
set TZData(:Antarctica/Rothera) {
|
||||
{-9223372036854775808 0 0 -00}
|
||||
{218246400 -10800 0 -03}
|
||||
{218246400 -10800 0 ROTT}
|
||||
}
|
||||
|
||||
@@ -2,5 +2,5 @@
|
||||
|
||||
set TZData(:Antarctica/Syowa) {
|
||||
{-9223372036854775808 0 0 -00}
|
||||
{-407808000 10800 0 +03}
|
||||
{-407808000 10800 0 SYOT}
|
||||
}
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user