summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjan.nijtmans <nijtmans@users.sourceforge.net>2019-01-31 22:35:03 (GMT)
committerjan.nijtmans <nijtmans@users.sourceforge.net>2019-01-31 22:35:03 (GMT)
commitbe020c7aa5cc7dd88dba8e81b14e6201edf7d23d (patch)
tree4df07aa00ddcc5df3075572a5c7698135e33f024
parenta2a2ad30624a13d9d6b5e73b6a73a5bc735ba606 (diff)
parentd0613a05568e1c78a1c0f7e499a334089ec7809b (diff)
downloadtcl-be020c7aa5cc7dd88dba8e81b14e6201edf7d23d.zip
tcl-be020c7aa5cc7dd88dba8e81b14e6201edf7d23d.tar.gz
tcl-be020c7aa5cc7dd88dba8e81b14e6201edf7d23d.tar.bz2
Merge 8.7
-rw-r--r--doc/ParseArgs.34
-rw-r--r--generic/tclBinary.c70
-rw-r--r--generic/tclInt.h4
3 files changed, 21 insertions, 57 deletions
diff --git a/doc/ParseArgs.3 b/doc/ParseArgs.3
index 0d26fa6..af58cbf 100644
--- a/doc/ParseArgs.3
+++ b/doc/ParseArgs.3
@@ -103,8 +103,8 @@ the argument's value. The following values are acceptable values for
\fBTCL_ARGV_CONSTANT\fR
.
The argument does not take any following value argument. If this argument is
-present, the int pointed to by the \fIsrcPtr\fR field is copied to the
-\fIdstPtr\fR field. The \fIclientData\fR field is ignored.
+present, the \fIsrcPtr\fR field (casted to \fIint\fR) is copied to the variable
+pointed to by the \fIdstPtr\fR field. The \fIclientData\fR field is ignored.
.TP
\fBTCL_ARGV_END\fR
.
diff --git a/generic/tclBinary.c b/generic/tclBinary.c
index 6760020..6b4a4f4 100644
--- a/generic/tclBinary.c
+++ b/generic/tclBinary.c
@@ -57,12 +57,9 @@
static void DupByteArrayInternalRep(Tcl_Obj *srcPtr,
Tcl_Obj *copyPtr);
-static void DupProperByteArrayInternalRep(Tcl_Obj *srcPtr,
- Tcl_Obj *copyPtr);
static int FormatNumber(Tcl_Interp *interp, int type,
Tcl_Obj *src, unsigned char **cursorPtr);
static void FreeByteArrayInternalRep(Tcl_Obj *objPtr);
-static void FreeProperByteArrayInternalRep(Tcl_Obj *objPtr);
static int GetFormatSpec(const char **formatPtr, char *cmdPtr,
int *countPtr, int *flagsPtr);
static Tcl_Obj * ScanNumber(unsigned char *buffer, int type,
@@ -248,10 +245,10 @@ static const EnsembleImplMap decodeMap[] = {
* over which bytearray values can be useful in the meanwhile.
*/
-static const Tcl_ObjType properByteArrayType = {
+const Tcl_ObjType tclPureByteArrayType = {
"bytearray",
- FreeProperByteArrayInternalRep,
- DupProperByteArrayInternalRep,
+ FreeByteArrayInternalRep,
+ DupByteArrayInternalRep,
UpdateStringOfByteArray,
NULL
};
@@ -287,13 +284,6 @@ typedef struct {
#define SET_BYTEARRAY(irPtr, baPtr) \
(irPtr)->twoPtrValue.ptr1 = (void *) (baPtr)
-int
-TclIsPureByteArray(
- Tcl_Obj * objPtr)
-{
- return objPtr->typePtr == &properByteArrayType;
-}
-
/*
*----------------------------------------------------------------------
*
@@ -420,7 +410,7 @@ Tcl_SetByteArrayObj(
}
SET_BYTEARRAY(&ir, byteArrayPtr);
- Tcl_StoreIntRep(objPtr, &properByteArrayType, &ir);
+ Tcl_StoreIntRep(objPtr, &tclPureByteArrayType, &ir);
}
/*
@@ -448,13 +438,13 @@ Tcl_GetByteArrayFromObj(
* array of bytes in the ByteArray object. */
{
ByteArray *baPtr;
- const Tcl_ObjIntRep *irPtr = TclFetchIntRep(objPtr, &properByteArrayType);
+ const Tcl_ObjIntRep *irPtr = TclFetchIntRep(objPtr, &tclPureByteArrayType);
if (irPtr == NULL) {
irPtr = TclFetchIntRep(objPtr, &tclByteArrayType);
if (irPtr == NULL) {
SetByteArrayFromAny(NULL, objPtr);
- irPtr = TclFetchIntRep(objPtr, &properByteArrayType);
+ irPtr = TclFetchIntRep(objPtr, &tclPureByteArrayType);
if (irPtr == NULL) {
irPtr = TclFetchIntRep(objPtr, &tclByteArrayType);
}
@@ -502,12 +492,12 @@ Tcl_SetByteArrayLength(
Tcl_Panic("%s called with shared object", "Tcl_SetByteArrayLength");
}
- irPtr = TclFetchIntRep(objPtr, &properByteArrayType);
+ irPtr = TclFetchIntRep(objPtr, &tclPureByteArrayType);
if (irPtr == NULL) {
irPtr = TclFetchIntRep(objPtr, &tclByteArrayType);
if (irPtr == NULL) {
SetByteArrayFromAny(NULL, objPtr);
- irPtr = TclFetchIntRep(objPtr, &properByteArrayType);
+ irPtr = TclFetchIntRep(objPtr, &tclPureByteArrayType);
if (irPtr == NULL) {
irPtr = TclFetchIntRep(objPtr, &tclByteArrayType);
}
@@ -553,7 +543,7 @@ SetByteArrayFromAny(
ByteArray *byteArrayPtr;
Tcl_ObjIntRep ir;
- if (objPtr->typePtr == &properByteArrayType) {
+ if (objPtr->typePtr == &tclPureByteArrayType) {
return TCL_OK;
}
if (objPtr->typePtr == &tclByteArrayType) {
@@ -577,7 +567,7 @@ SetByteArrayFromAny(
SET_BYTEARRAY(&ir, byteArrayPtr);
Tcl_StoreIntRep(objPtr,
- improper ? &tclByteArrayType : &properByteArrayType, &ir);
+ improper ? &tclByteArrayType : &tclPureByteArrayType, &ir);
return TCL_OK;
}
@@ -602,14 +592,7 @@ static void
FreeByteArrayInternalRep(
Tcl_Obj *objPtr) /* Object with internal rep to free. */
{
- Tcl_Free(GET_BYTEARRAY(TclFetchIntRep(objPtr, &tclByteArrayType)));
-}
-
-static void
-FreeProperByteArrayInternalRep(
- Tcl_Obj *objPtr) /* Object with internal rep to free. */
-{
- Tcl_Free(GET_BYTEARRAY(TclFetchIntRep(objPtr, &properByteArrayType)));
+ Tcl_Free(GET_BYTEARRAY(&(objPtr->internalRep)));
}
/*
@@ -638,28 +621,7 @@ DupByteArrayInternalRep(
ByteArray *srcArrayPtr, *copyArrayPtr;
Tcl_ObjIntRep ir;
- srcArrayPtr = GET_BYTEARRAY(TclFetchIntRep(srcPtr, &tclByteArrayType));
- length = srcArrayPtr->used;
-
- copyArrayPtr = Tcl_Alloc(BYTEARRAY_SIZE(length));
- copyArrayPtr->used = length;
- copyArrayPtr->allocated = length;
- memcpy(copyArrayPtr->bytes, srcArrayPtr->bytes, length);
-
- SET_BYTEARRAY(&ir, copyArrayPtr);
- Tcl_StoreIntRep(copyPtr, &tclByteArrayType, &ir);
-}
-
-static void
-DupProperByteArrayInternalRep(
- Tcl_Obj *srcPtr, /* Object with internal rep to copy. */
- Tcl_Obj *copyPtr) /* Object with internal rep to set. */
-{
- size_t length;
- ByteArray *srcArrayPtr, *copyArrayPtr;
- Tcl_ObjIntRep ir;
-
- srcArrayPtr = GET_BYTEARRAY(TclFetchIntRep(srcPtr, &properByteArrayType));
+ srcArrayPtr = GET_BYTEARRAY(&(srcPtr->internalRep));
length = srcArrayPtr->used;
copyArrayPtr = Tcl_Alloc(BYTEARRAY_SIZE(length));
@@ -668,7 +630,7 @@ DupProperByteArrayInternalRep(
memcpy(copyArrayPtr->bytes, srcArrayPtr->bytes, length);
SET_BYTEARRAY(&ir, copyArrayPtr);
- Tcl_StoreIntRep(copyPtr, &properByteArrayType, &ir);
+ Tcl_StoreIntRep(copyPtr, srcPtr->typePtr, &ir);
}
/*
@@ -693,7 +655,7 @@ UpdateStringOfByteArray(
Tcl_Obj *objPtr) /* ByteArray object whose string rep to
* update. */
{
- const Tcl_ObjIntRep *irPtr = TclFetchIntRep(objPtr, &properByteArrayType);
+ const Tcl_ObjIntRep *irPtr = TclFetchIntRep(objPtr, &tclPureByteArrayType);
ByteArray *byteArrayPtr = GET_BYTEARRAY(irPtr);
unsigned char *src = byteArrayPtr->bytes;
size_t i, length = byteArrayPtr->used;
@@ -763,12 +725,12 @@ TclAppendBytesToByteArray(
return;
}
- irPtr = TclFetchIntRep(objPtr, &properByteArrayType);
+ irPtr = TclFetchIntRep(objPtr, &tclPureByteArrayType);
if (irPtr == NULL) {
irPtr = TclFetchIntRep(objPtr, &tclByteArrayType);
if (irPtr == NULL) {
SetByteArrayFromAny(NULL, objPtr);
- irPtr = TclFetchIntRep(objPtr, &properByteArrayType);
+ irPtr = TclFetchIntRep(objPtr, &tclPureByteArrayType);
if (irPtr == NULL) {
irPtr = TclFetchIntRep(objPtr, &tclByteArrayType);
}
diff --git a/generic/tclInt.h b/generic/tclInt.h
index aa312c4..ca50f33 100644
--- a/generic/tclInt.h
+++ b/generic/tclInt.h
@@ -2680,6 +2680,7 @@ MODULE_SCOPE void *tclTimeClientData;
MODULE_SCOPE const Tcl_ObjType tclBignumType;
MODULE_SCOPE const Tcl_ObjType tclBooleanType;
MODULE_SCOPE const Tcl_ObjType tclByteArrayType;
+MODULE_SCOPE const Tcl_ObjType tclPureByteArrayType;
MODULE_SCOPE const Tcl_ObjType tclByteCodeType;
MODULE_SCOPE const Tcl_ObjType tclDoubleType;
MODULE_SCOPE const Tcl_ObjType tclIntType;
@@ -4572,7 +4573,8 @@ MODULE_SCOPE void TclDbInitNewObj(Tcl_Obj *objPtr, const char *file,
*----------------------------------------------------------------
*/
-MODULE_SCOPE int TclIsPureByteArray(Tcl_Obj *objPtr);
+#define TclIsPureByteArray(objPtr) \
+ ((objPtr)->typePtr==&tclPureByteArrayType)
#define TclIsPureDict(objPtr) \
(((objPtr)->bytes==NULL) && ((objPtr)->typePtr==&tclDictType))
#define TclFetchIntRep(objPtr, type) \