diff options
author | dgp <dgp@users.sourceforge.net> | 2005-04-08 20:03:43 (GMT) |
---|---|---|
committer | dgp <dgp@users.sourceforge.net> | 2005-04-08 20:03:43 (GMT) |
commit | 41e18fd7dc1745c26225b36db8e215cca756fa3d (patch) | |
tree | c057b88614cde6c0e7d8d9236a87529e68589735 /generic/tclCmdAH.c | |
parent | 0d5c0c748ea73b02b422d5cf116b12754a28775e (diff) | |
download | tcl-41e18fd7dc1745c26225b36db8e215cca756fa3d.zip tcl-41e18fd7dc1745c26225b36db8e215cca756fa3d.tar.gz tcl-41e18fd7dc1745c26225b36db8e215cca756fa3d.tar.bz2 |
* generic/tclInt.h (TclGetEncodingFromObj): New function to
* generic/tclEncoding.c (TclGetEncodingFromObj): retrieve a
Tcl_Encoding value, as well as cache it in the internal rep
of a new "encoding" Tcl_ObjType.
* generic/tclCmdAH.c (Tcl_EncodingObjCmd): Updated to call
new function so that Tcl_Encoding's used by [encoding convert*]
routines are not freed too quickly. [Bug 1077262]
Diffstat (limited to 'generic/tclCmdAH.c')
-rw-r--r-- | generic/tclCmdAH.c | 15 |
1 files changed, 6 insertions, 9 deletions
diff --git a/generic/tclCmdAH.c b/generic/tclCmdAH.c index 8a76602..1ef0dcf 100644 --- a/generic/tclCmdAH.c +++ b/generic/tclCmdAH.c @@ -11,7 +11,7 @@ * See the file "license.terms" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tclCmdAH.c,v 1.58 2005/01/21 17:42:12 andreas_kupries Exp $ + * RCS: @(#) $Id: tclCmdAH.c,v 1.59 2005/04/08 20:04:03 dgp Exp $ */ #include "tclInt.h" @@ -455,24 +455,21 @@ Tcl_EncodingObjCmd(dummy, interp, objc, objv) switch ((enum options) index) { case ENC_CONVERTTO: case ENC_CONVERTFROM: { - char *name; Tcl_Obj *data; if (objc == 3) { - name = NULL; + encoding = Tcl_GetEncoding(interp, NULL); data = objv[2]; } else if (objc == 4) { - name = TclGetString(objv[2]); + if (TclGetEncodingFromObj(interp, objv[2], &encoding) + != TCL_OK) { + return TCL_ERROR; + } data = objv[3]; } else { Tcl_WrongNumArgs(interp, 2, objv, "?encoding? data"); return TCL_ERROR; } - encoding = Tcl_GetEncoding(interp, name); - if (!encoding) { - return TCL_ERROR; - } - if ((enum options) index == ENC_CONVERTFROM) { /* * Treat the string as binary data. |