diff options
author | dgp <dgp@users.sourceforge.net> | 2012-07-19 15:08:23 (GMT) |
---|---|---|
committer | dgp <dgp@users.sourceforge.net> | 2012-07-19 15:08:23 (GMT) |
commit | 5bf41fe2eb79370375e30562f224f88cb98b33a5 (patch) | |
tree | d94b750cf65002836c0ef8fe10e84b9cd2b4aea6 /generic/tclUtil.c | |
parent | bc2133334d0fb3580be3b1cd65ed85b991887e68 (diff) | |
parent | 830b7864006fbd3ee3ac120aa17bf2416483a08d (diff) | |
download | tcl-5bf41fe2eb79370375e30562f224f88cb98b33a5.zip tcl-5bf41fe2eb79370375e30562f224f88cb98b33a5.tar.gz tcl-5bf41fe2eb79370375e30562f224f88cb98b33a5.tar.bz2 |
merge trunk
Diffstat (limited to 'generic/tclUtil.c')
-rw-r--r-- | generic/tclUtil.c | 41 |
1 files changed, 36 insertions, 5 deletions
diff --git a/generic/tclUtil.c b/generic/tclUtil.c index 1e35165..5c62cb7 100644 --- a/generic/tclUtil.c +++ b/generic/tclUtil.c @@ -2438,6 +2438,37 @@ Tcl_DStringAppend( /* *---------------------------------------------------------------------- * + * TclDStringAppendObj, TclDStringAppendDString -- + * + * Simple wrappers round Tcl_DStringAppend that make it easier to append + * from particular sources of strings. + * + *---------------------------------------------------------------------- + */ + +char * +TclDStringAppendObj( + Tcl_DString *dsPtr, + Tcl_Obj *objPtr) +{ + int length; + char *bytes = Tcl_GetStringFromObj(objPtr, &length); + + return Tcl_DStringAppend(dsPtr, bytes, length); +} + +char * +TclDStringAppendDString( + Tcl_DString *dsPtr, + Tcl_DString *toAppendPtr) +{ + return Tcl_DStringAppend(dsPtr, Tcl_DStringValue(toAppendPtr), + Tcl_DStringLength(toAppendPtr)); +} + +/* + *---------------------------------------------------------------------- + * * Tcl_DStringAppendElement -- * * Append a list element to the current value of a dynamic string. @@ -2744,9 +2775,9 @@ Tcl_DStringStartSublist( Tcl_DString *dsPtr) /* Dynamic string. */ { if (TclNeedSpace(dsPtr->string, dsPtr->string + dsPtr->length)) { - Tcl_DStringAppend(dsPtr, " {", -1); + TclDStringAppendLiteral(dsPtr, " {"); } else { - Tcl_DStringAppend(dsPtr, "{", -1); + TclDStringAppendLiteral(dsPtr, "{"); } } @@ -2772,7 +2803,7 @@ void Tcl_DStringEndSublist( Tcl_DString *dsPtr) /* Dynamic string. */ { - Tcl_DStringAppend(dsPtr, "}", -1); + TclDStringAppendLiteral(dsPtr, "}"); } /* @@ -3346,10 +3377,10 @@ static void UpdateStringOfEndOffset( register Tcl_Obj *objPtr) { - char buffer[TCL_INTEGER_SPACE + sizeof("end") + 1]; + char buffer[TCL_INTEGER_SPACE + 5]; register int len; - memcpy(buffer, "end", sizeof("end") + 1); + memcpy(buffer, "end", 4); len = sizeof("end") - 1; if (objPtr->internalRep.longValue != 0) { buffer[len++] = '-'; |