summaryrefslogtreecommitdiffstats
path: root/generic/tclStringObj.c
diff options
context:
space:
mode:
authordgp <dgp@users.sourceforge.net>2006-10-31 20:19:43 (GMT)
committerdgp <dgp@users.sourceforge.net>2006-10-31 20:19:43 (GMT)
commitce16019300e66b466f8ad327c5b3a03fe6876f8e (patch)
tree75652e34b31819c0360f9598db333054faffde99 /generic/tclStringObj.c
parent20c1156972864f916da62a217137e346eb93ac79 (diff)
downloadtcl-ce16019300e66b466f8ad327c5b3a03fe6876f8e.zip
tcl-ce16019300e66b466f8ad327c5b3a03fe6876f8e.tar.gz
tcl-ce16019300e66b466f8ad327c5b3a03fe6876f8e.tar.bz2
* generic/tclBasic.c: Refactored and renamed the routines
* generic/tclCkalloc.c: TclObjPrintf, TclFormatObj, and * generic/tclCmdAH.c: TclFormatToErrorInfo to a new set of * generic/tclCmdIL.c: routines TclAppendPrintfToObj, * generic/tclCmdMZ.c: TclAppendFormatToObj, TclObjPrintf, and * generic/tclDictObj.c: TclObjFormat, with the intent of making * generic/tclExecute.c: the latter list, plus TclAppendLimitedToObj * generic/tclIORChan.c: and TclAppendObjToErrorInfo, public via * generic/tclIOUtil.c: a revised TIP 270. * generic/tclInt.h: * generic/tclMain.c: * generic/tclNamesp.c: * generic/tclParseExpr.c: * generic/tclPkg.c: * generic/tclProc.c: * generic/tclStringObj.c: * generic/tclTimer.c: * generic/tclUtil.c: * unix/tclUnixFCmd.c:
Diffstat (limited to 'generic/tclStringObj.c')
-rw-r--r--generic/tclStringObj.c85
1 files changed, 60 insertions, 25 deletions
diff --git a/generic/tclStringObj.c b/generic/tclStringObj.c
index af94b6d..c3ba0f0 100644
--- a/generic/tclStringObj.c
+++ b/generic/tclStringObj.c
@@ -33,7 +33,7 @@
* 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.58 2006/09/24 20:46:40 msofer Exp $ */
+ * RCS: @(#) $Id: tclStringObj.c,v 1.59 2006/10/31 20:19:45 dgp Exp $ */
#include "tclInt.h"
#include "tommath.h"
@@ -51,9 +51,9 @@ static void AppendUtfToUnicodeRep(Tcl_Obj *objPtr,
static void AppendUtfToUtfRep(Tcl_Obj *objPtr,
CONST char *bytes, int numBytes);
static void FillUnicodeRep(Tcl_Obj *objPtr);
-static int FormatObjVA(Tcl_Interp *interp, Tcl_Obj *objPtr,
+static int AppendFormatToObjVA(Tcl_Interp *interp, Tcl_Obj *objPtr,
CONST char *format, va_list argList);
-static int ObjPrintfVA(Tcl_Interp *interp, Tcl_Obj *objPtr,
+static int AppendPrintfToObjVA(Tcl_Interp *interp, Tcl_Obj *objPtr,
CONST char *format, va_list argList);
static void FreeStringInternalRep(Tcl_Obj *objPtr);
static void DupStringInternalRep(Tcl_Obj *objPtr,
@@ -2293,7 +2293,7 @@ TclAppendFormattedObjs(
/*
*---------------------------------------------------------------------------
*
- * FormatObjVA --
+ * AppendFormatToObjVA --
*
* Populate the Unicode internal rep with the Unicode form of its string
* rep. The object must alread have a "String" internal rep.
@@ -2308,7 +2308,7 @@ TclAppendFormattedObjs(
*/
static int
-FormatObjVA(
+AppendFormatToObjVA(
Tcl_Interp *interp,
Tcl_Obj *objPtr,
CONST char *format,
@@ -2339,7 +2339,7 @@ FormatObjVA(
/*
*---------------------------------------------------------------------------
*
- * TclFormatObj --
+ * TclAppendFormatToObj --
*
* Results:
* A standard Tcl result.
@@ -2351,7 +2351,7 @@ FormatObjVA(
*/
int
-TclFormatObj(
+TclAppendFormatToObj(
Tcl_Interp *interp,
Tcl_Obj *objPtr,
CONST char *format,
@@ -2361,7 +2361,7 @@ TclFormatObj(
int result;
va_start(argList, format);
- result = FormatObjVA(interp, objPtr, format, argList);
+ result = AppendFormatToObjVA(interp, objPtr, format, argList);
va_end(argList);
return result;
}
@@ -2369,7 +2369,41 @@ TclFormatObj(
/*
*---------------------------------------------------------------------------
*
- * ObjPrintfVA --
+ * TclObjFormat--
+ *
+ * Results:
+ * A refcount zero Tcl_Obj.
+ *
+ * Side effects:
+ * None.
+ *
+ *---------------------------------------------------------------------------
+ */
+
+Tcl_Obj *
+TclObjFormat(
+ Tcl_Interp *interp,
+ CONST char *format,
+ ...)
+{
+ va_list argList;
+ int result;
+ Tcl_Obj *objPtr = Tcl_NewObj();
+
+ va_start(argList, format);
+ result = AppendFormatToObjVA(interp, objPtr, format, argList);
+ va_end(argList);
+ if (result != TCL_OK) {
+ Tcl_DecrRefCount(objPtr);
+ return NULL;
+ }
+ return objPtr;
+}
+
+/*
+ *---------------------------------------------------------------------------
+ *
+ * AppendPrintfToObjVA --
*
* Results:
*
@@ -2379,7 +2413,7 @@ TclFormatObj(
*/
static int
-ObjPrintfVA(
+AppendPrintfToObjVA(
Tcl_Interp *interp,
Tcl_Obj *objPtr,
CONST char *format,
@@ -2510,7 +2544,7 @@ ObjPrintfVA(
/*
*---------------------------------------------------------------------------
*
- * TclObjPrintf --
+ * TclAppendPrintfToObj --
*
* Results:
* A standard Tcl result.
@@ -2522,7 +2556,7 @@ ObjPrintfVA(
*/
int
-TclObjPrintf(
+TclAppendPrintfToObj(
Tcl_Interp *interp,
Tcl_Obj *objPtr,
CONST char *format,
@@ -2532,42 +2566,43 @@ TclObjPrintf(
int result;
va_start(argList, format);
- result = ObjPrintfVA(interp, objPtr, format, argList);
+ result = AppendPrintfToObjVA(interp, objPtr, format, argList);
va_end(argList);
return result;
}
/*
- *----------------------------------------------------------------------
+ *---------------------------------------------------------------------------
*
- * TclFormatToErrorInfo --
+ * TclObjPrintf --
*
* Results:
+ * A refcount zero Tcl_Obj.
*
* Side effects:
+ * None.
*
- *----------------------------------------------------------------------
+ *---------------------------------------------------------------------------
*/
-int
-TclFormatToErrorInfo(
+Tcl_Obj *
+TclObjPrintf(
Tcl_Interp *interp,
CONST char *format,
...)
{
- int code;
va_list argList;
+ int result;
Tcl_Obj *objPtr = Tcl_NewObj();
va_start(argList, format);
- code = ObjPrintfVA(interp, objPtr, format, argList);
+ result = AppendPrintfToObjVA(interp, objPtr, format, argList);
va_end(argList);
- if (code != TCL_OK) {
- return code;
+ if (result != TCL_OK) {
+ Tcl_DecrRefCount(objPtr);
+ return NULL;
}
- TclAppendObjToErrorInfo(interp, objPtr);
- Tcl_DecrRefCount(objPtr);
- return TCL_OK;
+ return objPtr;
}
/*