summaryrefslogtreecommitdiffstats
path: root/generic
diff options
context:
space:
mode:
Diffstat (limited to 'generic')
-rw-r--r--generic/tclStringObj.c38
-rw-r--r--generic/tclTestObj.c21
2 files changed, 25 insertions, 34 deletions
diff --git a/generic/tclStringObj.c b/generic/tclStringObj.c
index 8dc6e90..09cfc4c 100644
--- a/generic/tclStringObj.c
+++ b/generic/tclStringObj.c
@@ -31,7 +31,7 @@ A Unicode string
* See the file "license.terms" for information on usage and redistribution
* of this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: @(#) $Id: tclStringObj.c,v 1.8 1999/06/15 01:16:25 hershey Exp $
+ * RCS: @(#) $Id: tclStringObj.c,v 1.9 1999/06/15 03:14:44 hershey Exp $
*/
#include "tclInt.h"
@@ -793,31 +793,18 @@ Tcl_AppendToObj(objPtr, bytes, length)
}
/*
- * TEMPORARY!!! This is terribly inefficient, but it works, and Don
- * needs for me to check this stuff in ASAP. -Melissa
- */
-
-/* printf("called Tcl_AppendToObj with str = %s\n", bytes); */
- UpdateStringOfString(objPtr);
- AppendUtfToUtfRep(objPtr, bytes, length);
- return;
-
- /*
* If objPtr has a valid Unicode rep, then append the Unicode
* conversion of "bytes" to the objPtr's Unicode rep, otherwise
* append "bytes" to objPtr's string rep.
*/
stringPtr = GET_STRING(objPtr);
- if (stringPtr->allocated > 0) {
+ if (stringPtr->uallocated > 0) {
AppendUtfToUnicodeRep(objPtr, bytes, length);
stringPtr = GET_STRING(objPtr);
-/* printf(" ended Tcl_AppendToObj with %d unicode chars.\n", */
-/* stringPtr->numChars); */
} else {
AppendUtfToUtfRep(objPtr, bytes, length);
-/* printf(" ended Tcl_AppendToObj with str = %s\n", objPtr->bytes); */
}
}
@@ -862,9 +849,9 @@ Tcl_AppendUnicodeToObj(objPtr, unicode, length)
* needs for me to check this stuff in ASAP. -Melissa
*/
- UpdateStringOfString(objPtr);
- AppendUnicodeToUtfRep(objPtr, unicode, length);
- return;
+/* UpdateStringOfString(objPtr); */
+/* AppendUnicodeToUtfRep(objPtr, unicode, length); */
+/* return; */
/*
* If objPtr has a valid Unicode rep, then append the "unicode"
@@ -873,7 +860,7 @@ Tcl_AppendUnicodeToObj(objPtr, unicode, length)
*/
stringPtr = GET_STRING(objPtr);
- if (stringPtr->allocated > 0) {
+ if (stringPtr->uallocated > 0) {
AppendUnicodeToUnicodeRep(objPtr, unicode, length);
} else {
AppendUnicodeToUtfRep(objPtr, unicode, length);
@@ -910,22 +897,12 @@ Tcl_AppendObjToObj(objPtr, appendObjPtr)
SetStringFromAny(NULL, objPtr);
/*
- * TEMPORARY!!! This is terribly inefficient, but it works, and Don
- * needs for me to check this stuff in ASAP. -Melissa
- */
-
- UpdateStringOfString(objPtr);
- bytes = Tcl_GetStringFromObj(appendObjPtr, &length);
- AppendUtfToUtfRep(objPtr, bytes, length);
- return;
-
- /*
* If objPtr has a valid Unicode rep, then get a Unicode string
* from appendObjPtr and append it.
*/
stringPtr = GET_STRING(objPtr);
- if (stringPtr->allocated > 0) {
+ if (stringPtr->uallocated > 0) {
/*
* If appendObjPtr is not of the "String" type, don't convert it.
@@ -1047,7 +1024,6 @@ AppendUnicodeToUtfRep(objPtr, unicode, numChars)
int numChars; /* Number of chars of "unicode" to convert. */
{
Tcl_DString dsPtr;
- int length = numChars * sizeof(Tcl_UniChar);
char *bytes;
if (numChars == 0) {
diff --git a/generic/tclTestObj.c b/generic/tclTestObj.c
index 533b967..259fcbd 100644
--- a/generic/tclTestObj.c
+++ b/generic/tclTestObj.c
@@ -12,7 +12,7 @@
* See the file "license.terms" for information on usage and redistribution
* of this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: @(#) $Id: tclTestObj.c,v 1.4 1999/06/08 02:59:26 hershey Exp $
+ * RCS: @(#) $Id: tclTestObj.c,v 1.5 1999/06/15 03:14:45 hershey Exp $
*/
#include "tclInt.h"
@@ -58,6 +58,14 @@ static int TestobjCmd _ANSI_ARGS_((ClientData dummy,
static int TeststringobjCmd _ANSI_ARGS_((ClientData dummy,
Tcl_Interp *interp, int objc,
Tcl_Obj *CONST objv[]));
+
+typedef struct TestString {
+ int numChars;
+ size_t allocated;
+ size_t uallocated;
+ Tcl_UniChar unicode[2];
+} TestString;
+
/*
*----------------------------------------------------------------------
@@ -872,6 +880,7 @@ TeststringobjCmd(clientData, interp, objc, objv)
int varIndex, option, i, length;
#define MAX_STRINGS 11
char *index, *string, *strings[MAX_STRINGS+1];
+ TestString *strPtr;
static char *options[] = {
"append", "appendstrings", "get", "get2", "length", "length2",
"set", "set2", "setlength", (char *) NULL
@@ -974,8 +983,14 @@ TeststringobjCmd(clientData, interp, objc, objv)
if (objc != 3) {
goto wrongNumArgs;
}
- Tcl_SetIntObj(Tcl_GetObjResult(interp), (varPtr[varIndex] != NULL)
- ? (int) varPtr[varIndex]->internalRep.longValue : -1);
+ if (varPtr[varIndex] != NULL) {
+ strPtr = (TestString *)
+ (varPtr[varIndex])->internalRep.otherValuePtr;
+ length = (int) strPtr->allocated;
+ } else {
+ length = -1;
+ }
+ Tcl_SetIntObj(Tcl_GetObjResult(interp), length);
break;
case 6: /* set */
if (objc != 4) {