diff options
author | jan.nijtmans <nijtmans@users.sourceforge.net> | 2013-01-02 14:30:30 (GMT) |
---|---|---|
committer | jan.nijtmans <nijtmans@users.sourceforge.net> | 2013-01-02 14:30:30 (GMT) |
commit | 8214e44b57a7ed7914a9d3eb4de78d298402edf0 (patch) | |
tree | 51f4f029ebd5893bc62dcc7b5f35078b6b9bf25c | |
parent | d967827b739973e53a0ca4e78ad873ee45949160 (diff) | |
parent | 3f4534b92ba967574dc4106bc346ccbbfed9d638 (diff) | |
download | tcl-8214e44b57a7ed7914a9d3eb4de78d298402edf0.zip tcl-8214e44b57a7ed7914a9d3eb4de78d298402edf0.tar.gz tcl-8214e44b57a7ed7914a9d3eb4de78d298402edf0.tar.bz2 |
test Tcl_GetErrorLine() forwards/backwards compatibility in pkgb.so as well.
Marked some string subcommands as obsolete, following discussion on tcl-core.
Don't free ctrl.script if thread creation fails: it is a constant string "testthread wait" normally.
-rw-r--r-- | ChangeLog | 6 | ||||
-rw-r--r-- | doc/string.n | 31 | ||||
-rw-r--r-- | generic/tclThreadTest.c | 17 | ||||
-rw-r--r-- | unix/dltest/pkgb.c | 7 |
4 files changed, 39 insertions, 22 deletions
@@ -1,3 +1,9 @@ +2012-12-31 Donal K. Fellows <dkf@users.sf.net> + + * doc/string.n: Noted the obsolescence of the 'bytelength', + 'wordstart' and 'wordend' subcommands, and moved them to later in the + file. + 2012-12-27 Jan Nijtmans <nijtmans@users.sf.net> * generic/tclListObj.c: [Bug 3598580]: Tcl_ListObjReplace may release diff --git a/doc/string.n b/doc/string.n index dfb5a90..e74b8a2 100644 --- a/doc/string.n +++ b/doc/string.n @@ -20,16 +20,6 @@ string \- Manipulate strings Performs one of several string operations, depending on \fIoption\fR. The legal \fIoption\fRs (which may be abbreviated) are: .TP -\fBstring bytelength \fIstring\fR -Returns a decimal string giving the number of bytes used to represent -\fIstring\fR in memory. Because UTF\-8 uses one to three bytes to -represent Unicode characters, the byte length will not be the same as -the character length in general. The cases where a script cares about -the byte length are rare. In almost all cases, you should use the -\fBstring length\fR operation (including determining the length of a -Tcl ByteArray object). Refer to the \fBTcl_NumUtfChars\fR manual -entry for more details on the UTF\-8 representation. -.TP \fBstring compare\fR ?\fB\-nocase\fR? ?\fB\-length int\fR? \fIstring1 string2\fR Perform a character-by-character comparison of strings \fIstring1\fR and \fIstring2\fR. Returns \-1, 0, or 1, depending on whether @@ -128,7 +118,7 @@ empty string returns 0, otherwise an empty string will return 1 on any class. If \fB\-failindex\fR is specified, then if the function returns 0, the index in the string where the class was no longer valid will be stored in the variable named \fIvarname\fR. The \fIvarname\fR -will not be set if the function returns 1. The following character +will not be set if \fBstring is\fR returns 1. The following character classes are recognized (the class name can be abbreviated): .RS .IP \fBalnum\fR 12 @@ -355,6 +345,21 @@ Returns a value equal to \fIstring\fR except that any trailing characters present in the string given by \fIchars\fR are removed. If \fIchars\fR is not specified then white space is removed (spaces, tabs, newlines, and carriage returns). +.SH "OBSOLETE SUBCOMMANDS" +.PP +These subcommands are currently supported, but are likely to go away in a +future release as their functionality is either virtually never used or highly +misleading. +.TP +\fBstring bytelength \fIstring\fR +Returns a decimal string giving the number of bytes used to represent +\fIstring\fR in memory. Because UTF\-8 uses one to three bytes to +represent Unicode characters, the byte length will not be the same as +the character length in general. The cases where a script cares about +the byte length are rare. In almost all cases, you should use the +\fBstring length\fR operation (including determining the length of a +Tcl ByteArray object). Refer to the \fBTcl_NumUtfChars\fR manual +entry for more details on the UTF\-8 representation. .TP \fBstring wordend \fIstring charIndex\fR Returns the index of the character just after the last one in the word @@ -377,9 +382,9 @@ prefix of the string \fBfoobar\fR. .CS set length [\fBstring length\fR $string] if {$length == 0} { - set isPrefix 0 + set isPrefix 0 } else { - set isPrefix [\fBstring equal\fR -length $length $string "foobar"] + set isPrefix [\fBstring equal\fR -length $length $string "foobar"] } .CE diff --git a/generic/tclThreadTest.c b/generic/tclThreadTest.c index 960c7dc..d032cc6 100644 --- a/generic/tclThreadTest.c +++ b/generic/tclThreadTest.c @@ -57,7 +57,7 @@ static struct ThreadSpecificData *threadList; */ typedef struct ThreadCtrl { - char *script; /* The Tcl command this thread should + const char *script; /* The Tcl command this thread should * execute */ int flags; /* Initial value of the "flags" field in the * ThreadSpecificData structure for the new @@ -120,11 +120,11 @@ EXTERN int TclThread_Init(Tcl_Interp *interp); EXTERN int Tcl_ThreadObjCmd(ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[]); -EXTERN int TclCreateThread(Tcl_Interp *interp, char *script, +EXTERN int TclCreateThread(Tcl_Interp *interp, const char *script, int joinable); EXTERN int TclThreadList(Tcl_Interp *interp); EXTERN int TclThreadSend(Tcl_Interp *interp, Tcl_ThreadId id, - char *script, int wait); + const char *script, int wait); #undef TCL_STORAGE_CLASS #define TCL_STORAGE_CLASS DLLIMPORT @@ -234,7 +234,7 @@ Tcl_ThreadObjCmd( switch ((enum options)option) { case THREAD_CREATE: { - char *script; + const char *script; int joinable, len; if (objc == 2) { @@ -331,7 +331,7 @@ Tcl_ThreadObjCmd( return TclThreadList(interp); case THREAD_SEND: { long id; - char *script; + const char *script; int wait, arg; if ((objc != 4) && (objc != 5)) { @@ -407,7 +407,7 @@ Tcl_ThreadObjCmd( int TclCreateThread( Tcl_Interp *interp, /* Current interpreter. */ - char *script, /* Script to execute */ + const char *script, /* Script to execute */ int joinable) /* Flag, joinable thread or not */ { ThreadCtrl ctrl; @@ -424,7 +424,6 @@ TclCreateThread( TCL_THREAD_STACK_DEFAULT, joinable) != TCL_OK) { Tcl_MutexUnlock(&threadMutex); Tcl_AppendResult(interp, "can't create a new thread", NULL); - ckfree((char *) ctrl.script); return TCL_ERROR; } @@ -705,7 +704,7 @@ int TclThreadSend( Tcl_Interp *interp, /* The current interpreter. */ Tcl_ThreadId id, /* Thread Id of other interpreter. */ - char *script, /* The script to evaluate. */ + const char *script, /* The script to evaluate. */ int wait) /* If 1, we block for the result. */ { ThreadSpecificData *tsdPtr = TCL_TSD_INIT(&dataKey); @@ -1035,7 +1034,7 @@ ThreadExitProc( * going to call free on it. */ - char *msg = "target thread died"; + const char *msg = "target thread died"; resultPtr->result = ckalloc(strlen(msg)+1); strcpy(resultPtr->result, msg); diff --git a/unix/dltest/pkgb.c b/unix/dltest/pkgb.c index 3338eb5..039ad91 100644 --- a/unix/dltest/pkgb.c +++ b/unix/dltest/pkgb.c @@ -39,6 +39,10 @@ static int Pkgb_UnsafeObjCmd(ClientData clientData, *---------------------------------------------------------------------- */ +#ifndef Tcl_GetErrorLine +# define Tcl_GetErrorLine(interp) ((interp)->errorLine) +#endif + static int Pkgb_SubObjCmd( ClientData dummy, /* Not used. */ @@ -54,6 +58,9 @@ Pkgb_SubObjCmd( } if ((Tcl_GetIntFromObj(interp, objv[1], &first) != TCL_OK) || (Tcl_GetIntFromObj(interp, objv[2], &second) != TCL_OK)) { + char buf[TCL_INTEGER_SPACE]; + sprintf(buf, "%d", Tcl_GetErrorLine(interp)); + Tcl_AppendResult(interp, " in line: ", buf, NULL); return TCL_ERROR; } Tcl_SetObjResult(interp, Tcl_NewIntObj(first - second)); |