summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjan.nijtmans <nijtmans@users.sourceforge.net>2019-01-26 17:32:49 (GMT)
committerjan.nijtmans <nijtmans@users.sourceforge.net>2019-01-26 17:32:49 (GMT)
commitc1452de7e5857e14cb7c6a92518721637a0dc590 (patch)
treebe466aebb5d2768ca30cff1773f92e6775ea9884
parent918813166cac0372ced8a1e2e8f4cf8192a169dd (diff)
parenta6393381ec5d16f9f82c4b8ee992bedaa7c1e4a9 (diff)
downloadtcl-c1452de7e5857e14cb7c6a92518721637a0dc590.zip
tcl-c1452de7e5857e14cb7c6a92518721637a0dc590.tar.gz
tcl-c1452de7e5857e14cb7c6a92518721637a0dc590.tar.bz2
Merge 8.7
-rw-r--r--compat/strtol.c2
-rw-r--r--compat/strtoul.c2
-rw-r--r--generic/tcl.h2
-rw-r--r--generic/tclInt.h12
-rw-r--r--generic/tclLiteral.c41
-rw-r--r--generic/tclObj.c6
-rw-r--r--generic/tclParse.c47
-rw-r--r--generic/tclParse.h2
-rw-r--r--generic/tclTest.c2
-rw-r--r--library/http/cookiejar.tcl2
10 files changed, 44 insertions, 74 deletions
diff --git a/compat/strtol.c b/compat/strtol.c
index 811006a..b7f6919 100644
--- a/compat/strtol.c
+++ b/compat/strtol.c
@@ -53,7 +53,7 @@ strtol(
*/
p = string;
- while (isspace(UCHAR(*p))) {
+ while (TclIsSpaceProc(*p)) {
p += 1;
}
diff --git a/compat/strtoul.c b/compat/strtoul.c
index 15587f1..e37eb05 100644
--- a/compat/strtoul.c
+++ b/compat/strtoul.c
@@ -74,7 +74,7 @@ strtoul(
*/
p = string;
- while (isspace(UCHAR(*p))) {
+ while (TclIsSpaceProc(*p)) {
p += 1;
}
if (*p == '-') {
diff --git a/generic/tcl.h b/generic/tcl.h
index bd2612c..a0fd3b3 100644
--- a/generic/tcl.h
+++ b/generic/tcl.h
@@ -627,7 +627,7 @@ typedef union Tcl_ObjIntRep { /* The internal representation: */
/* not used internally any more. */
Tcl_WideInt wideValue; /* - an integer value >= 64bits */
struct { /* - internal rep as two pointers. */
- void *ptr1;
+ void *ptr1;
void *ptr2;
} twoPtrValue;
struct { /* - internal rep as a pointer and a long, */
diff --git a/generic/tclInt.h b/generic/tclInt.h
index e9404cd..f820b57 100644
--- a/generic/tclInt.h
+++ b/generic/tclInt.h
@@ -3011,8 +3011,8 @@ MODULE_SCOPE void TclInitNotifier(void);
MODULE_SCOPE void TclInitObjSubsystem(void);
MODULE_SCOPE void TclInitSubsystems(void);
MODULE_SCOPE int TclInterpReady(Tcl_Interp *interp);
-MODULE_SCOPE int TclIsSpaceProc(char byte);
-MODULE_SCOPE int TclIsBareword(char byte);
+MODULE_SCOPE int TclIsSpaceProc(int byte);
+MODULE_SCOPE int TclIsBareword(int byte);
MODULE_SCOPE Tcl_Obj * TclJoinPath(int elements, Tcl_Obj * const objv[],
int forceRelative);
MODULE_SCOPE int TclJoinThread(Tcl_ThreadId id, int *result);
@@ -4902,10 +4902,10 @@ MODULE_SCOPE Tcl_PackageInitProc Procbodytest_SafeInit;
} while (0)
#endif /* TCL_MEM_DEBUG */
-/*
- * Macros to convert size_t to wide-int (and wide-int object) considering
- * platform-related negative value ((size_t)-1), if wide-int and size_t
- * have different dimensions (e. g. 32-bit platform).
+/*
+ * Macros to convert size_t to wide-int (and wide-int object) considering
+ * platform-related negative value ((size_t)-1), if wide-int and size_t
+ * have different dimensions (e. g. 32-bit platform).
*/
#if (!defined(TCL_WIDE_INT_IS_LONG) || (LONG_MAX > UINT_MAX)) && (SIZE_MAX <= UINT_MAX)
diff --git a/generic/tclLiteral.c b/generic/tclLiteral.c
index 01f8a71..3ece98b 100644
--- a/generic/tclLiteral.c
+++ b/generic/tclLiteral.c
@@ -200,25 +200,36 @@ TclCreateLiteral(
for (globalPtr=globalTablePtr->buckets[globalHash] ; globalPtr!=NULL;
globalPtr = globalPtr->nextPtr) {
objPtr = globalPtr->objPtr;
- if ((globalPtr->nsPtr == nsPtr)
- && ((size_t)objPtr->length == length) && ((length == 0)
- || ((objPtr->bytes[0] == bytes[0])
- && (memcmp(objPtr->bytes, bytes, length) == 0)))) {
+ if (globalPtr->nsPtr == nsPtr) {
/*
- * A literal was found: return it
+ * Literals should always have UTF-8 representations... but this
+ * is not guaranteed so we need to be careful anyway.
+ *
+ * https://stackoverflow.com/q/54337750/301832
*/
- if (newPtr) {
- *newPtr = 0;
- }
- if (globalPtrPtr) {
- *globalPtrPtr = globalPtr;
- }
- if ((flags & LITERAL_ON_HEAP)) {
- Tcl_Free((void *)bytes);
+ size_t objLength;
+ char *objBytes = TclGetStringFromObj(objPtr, &objLength);
+
+ if ((objLength == length) && ((length == 0)
+ || ((objBytes[0] == bytes[0])
+ && (memcmp(objBytes, bytes, (unsigned) length) == 0)))) {
+ /*
+ * A literal was found: return it
+ */
+
+ if (newPtr) {
+ *newPtr = 0;
+ }
+ if (globalPtrPtr) {
+ *globalPtrPtr = globalPtr;
+ }
+ if (flags & LITERAL_ON_HEAP) {
+ Tcl_Free((void *)bytes);
+ }
+ globalPtr->refCount++;
+ return objPtr;
}
- globalPtr->refCount++;
- return objPtr;
}
}
if (!newPtr) {
diff --git a/generic/tclObj.c b/generic/tclObj.c
index 6e3db3e..9807cb2 100644
--- a/generic/tclObj.c
+++ b/generic/tclObj.c
@@ -1701,12 +1701,12 @@ Tcl_GetStringFromObj(
* (objPtr->bytes != NULL && bytes != NULL) || (numBytes == -1)
* Invalid call -- panic!
*
- * objPtr->bytes == NULL && bytes == NULL && numBytes >= 0
+ * objPtr->bytes == NULL && bytes == NULL && numBytes != -1
* Allocation only - allocate space for (numBytes+1) chars.
* store in objPtr->bytes and return. Also sets
* objPtr->length to 0 and objPtr->bytes[0] to NUL.
*
- * objPtr->bytes == NULL && bytes != NULL && numBytes >= 0
+ * objPtr->bytes == NULL && bytes != NULL && numBytes != -1
* Allocate and copy. bytes is assumed to point to chars to
* copy into the string rep. objPtr->length = numBytes. Allocate
* array of (numBytes + 1) chars. store in objPtr->bytes. Copy
@@ -1715,7 +1715,7 @@ Tcl_GetStringFromObj(
* Caller must guarantee there are numBytes chars at bytes to
* be copied.
*
- * objPtr->bytes != NULL && bytes == NULL && numBytes >= 0
+ * objPtr->bytes != NULL && bytes == NULL && numBytes != -1
* Truncate. Set objPtr->length to numBytes and
* objPr->bytes[numBytes] to NUL. Caller has to guarantee
* that a prior allocating call allocated enough bytes for
diff --git a/generic/tclParse.c b/generic/tclParse.c
index b2a4e23..7259567 100644
--- a/generic/tclParse.c
+++ b/generic/tclParse.c
@@ -19,12 +19,7 @@
/*
* The following table provides parsing information about each possible 8-bit
- * character. The table is designed to be referenced with either signed or
- * unsigned characters, so it has 384 entries. The first 128 entries
- * correspond to negative character values, the next 256 correspond to
- * positive character values. The last 128 entries are identical to the first
- * 128. The table is always indexed with a 128-byte offset (the 128th entry
- * corresponds to a character value of 0).
+ * character. The table is designed to be referenced with unsigned characters.
*
* The macro CHAR_TYPE is used to index into the table and return information
* about its character argument. The following return values are defined.
@@ -44,42 +39,6 @@
*/
const char tclCharTypeTable[] = {
- /*
- * Negative character values, from -128 to -1:
- */
-
- TYPE_NORMAL, TYPE_NORMAL, TYPE_NORMAL, TYPE_NORMAL,
- TYPE_NORMAL, TYPE_NORMAL, TYPE_NORMAL, TYPE_NORMAL,
- TYPE_NORMAL, TYPE_NORMAL, TYPE_NORMAL, TYPE_NORMAL,
- TYPE_NORMAL, TYPE_NORMAL, TYPE_NORMAL, TYPE_NORMAL,
- TYPE_NORMAL, TYPE_NORMAL, TYPE_NORMAL, TYPE_NORMAL,
- TYPE_NORMAL, TYPE_NORMAL, TYPE_NORMAL, TYPE_NORMAL,
- TYPE_NORMAL, TYPE_NORMAL, TYPE_NORMAL, TYPE_NORMAL,
- TYPE_NORMAL, TYPE_NORMAL, TYPE_NORMAL, TYPE_NORMAL,
- TYPE_NORMAL, TYPE_NORMAL, TYPE_NORMAL, TYPE_NORMAL,
- TYPE_NORMAL, TYPE_NORMAL, TYPE_NORMAL, TYPE_NORMAL,
- TYPE_NORMAL, TYPE_NORMAL, TYPE_NORMAL, TYPE_NORMAL,
- TYPE_NORMAL, TYPE_NORMAL, TYPE_NORMAL, TYPE_NORMAL,
- TYPE_NORMAL, TYPE_NORMAL, TYPE_NORMAL, TYPE_NORMAL,
- TYPE_NORMAL, TYPE_NORMAL, TYPE_NORMAL, TYPE_NORMAL,
- TYPE_NORMAL, TYPE_NORMAL, TYPE_NORMAL, TYPE_NORMAL,
- TYPE_NORMAL, TYPE_NORMAL, TYPE_NORMAL, TYPE_NORMAL,
- TYPE_NORMAL, TYPE_NORMAL, TYPE_NORMAL, TYPE_NORMAL,
- TYPE_NORMAL, TYPE_NORMAL, TYPE_NORMAL, TYPE_NORMAL,
- TYPE_NORMAL, TYPE_NORMAL, TYPE_NORMAL, TYPE_NORMAL,
- TYPE_NORMAL, TYPE_NORMAL, TYPE_NORMAL, TYPE_NORMAL,
- TYPE_NORMAL, TYPE_NORMAL, TYPE_NORMAL, TYPE_NORMAL,
- TYPE_NORMAL, TYPE_NORMAL, TYPE_NORMAL, TYPE_NORMAL,
- TYPE_NORMAL, TYPE_NORMAL, TYPE_NORMAL, TYPE_NORMAL,
- TYPE_NORMAL, TYPE_NORMAL, TYPE_NORMAL, TYPE_NORMAL,
- TYPE_NORMAL, TYPE_NORMAL, TYPE_NORMAL, TYPE_NORMAL,
- TYPE_NORMAL, TYPE_NORMAL, TYPE_NORMAL, TYPE_NORMAL,
- TYPE_NORMAL, TYPE_NORMAL, TYPE_NORMAL, TYPE_NORMAL,
- TYPE_NORMAL, TYPE_NORMAL, TYPE_NORMAL, TYPE_NORMAL,
- TYPE_NORMAL, TYPE_NORMAL, TYPE_NORMAL, TYPE_NORMAL,
- TYPE_NORMAL, TYPE_NORMAL, TYPE_NORMAL, TYPE_NORMAL,
- TYPE_NORMAL, TYPE_NORMAL, TYPE_NORMAL, TYPE_NORMAL,
- TYPE_NORMAL, TYPE_NORMAL, TYPE_NORMAL, TYPE_NORMAL,
/*
* Positive character values, from 0-127:
@@ -593,7 +552,7 @@ Tcl_ParseCommand(
int
TclIsSpaceProc(
- char byte)
+ int byte)
{
return CHAR_TYPE(byte) & (TYPE_SPACE) || byte == '\n';
}
@@ -622,7 +581,7 @@ TclIsSpaceProc(
int
TclIsBareword(
- char byte)
+ int byte)
{
if (byte < '0' || byte > 'z') {
return 0;
diff --git a/generic/tclParse.h b/generic/tclParse.h
index 20c609c..5f75c9a 100644
--- a/generic/tclParse.h
+++ b/generic/tclParse.h
@@ -12,6 +12,6 @@
#define TYPE_CLOSE_BRACK 0x20
#define TYPE_BRACE 0x40
-#define CHAR_TYPE(c) (tclCharTypeTable+128)[(int)(c)]
+#define CHAR_TYPE(c) tclCharTypeTable[(unsigned char)(c)]
MODULE_SCOPE const char tclCharTypeTable[];
diff --git a/generic/tclTest.c b/generic/tclTest.c
index d3e064a..08669db 100644
--- a/generic/tclTest.c
+++ b/generic/tclTest.c
@@ -4982,7 +4982,7 @@ TestpurebytesobjObjCmd(
if (objc == 2) {
const char *s = Tcl_GetString(objv[1]);
objPtr->length = objv[1]->length;
- objPtr->bytes = ckalloc(objPtr->length + 1);
+ objPtr->bytes = Tcl_Alloc(objPtr->length + 1);
memcpy(objPtr->bytes, s, objPtr->length);
objPtr->bytes[objPtr->length] = 0;
}
diff --git a/library/http/cookiejar.tcl b/library/http/cookiejar.tcl
index 5b424b9..4aea842 100644
--- a/library/http/cookiejar.tcl
+++ b/library/http/cookiejar.tcl
@@ -458,7 +458,7 @@ package provide cookiejar \
log info "constructed domain info with %d entries" $n
}
- # This forces the rebuild of the domain data, loading it from
+ # This forces the rebuild of the domain data, loading it from
method forceLoadDomainData {} {
db transaction {
db eval {