diff options
Diffstat (limited to 'doc/SplitList.3')
| -rw-r--r-- | doc/SplitList.3 | 55 |
1 files changed, 26 insertions, 29 deletions
diff --git a/doc/SplitList.3 b/doc/SplitList.3 index e30771c..3439f2e 100644 --- a/doc/SplitList.3 +++ b/doc/SplitList.3 @@ -5,13 +5,11 @@ '\" See the file "license.terms" for information on usage and redistribution '\" of this file, and for a DISCLAIMER OF ALL WARRANTIES. '\" -'\" RCS: @(#) $Id: SplitList.3,v 1.2 1998/09/14 18:39:50 stanton Exp $ -'\" +.TH Tcl_SplitList 3 8.0 Tcl "Tcl Library Procedures" .so man.macros -.TH Tcl_SplitList 3 7.5 Tcl "Tcl Library Procedures" .BS .SH NAME -Tcl_SplitList, Tcl_Merge, Tcl_ScanElement, Tcl_ConvertElement \- manipulate Tcl lists +Tcl_SplitList, Tcl_Merge, Tcl_ScanElement, Tcl_ConvertElement, Tcl_ScanCountedElement, Tcl_ConvertCountedElement \- manipulate Tcl lists .SH SYNOPSIS .nf \fB#include <tcl.h>\fR @@ -24,49 +22,41 @@ char * .sp int \fBTcl_ScanElement\fR(\fIsrc, flagsPtr\fR) -.VS .sp int \fBTcl_ScanCountedElement\fR(\fIsrc, length, flagsPtr\fR) -.VE .sp int \fBTcl_ConvertElement\fR(\fIsrc, dst, flags\fR) -.VS .sp int \fBTcl_ConvertCountedElement\fR(\fIsrc, length, dst, flags\fR) -.VE .SH ARGUMENTS -.AS Tcl_Interp ***argvPtr +.AS "const char *const" ***argvPtr out .AP Tcl_Interp *interp out -.VS Interpreter to use for error reporting. If NULL, then no error message is left. -.VE .AP char *list in Pointer to a string with proper list structure. .AP int *argcPtr out Filled in with number of elements in \fIlist\fR. -.AP char ***argvPtr out +.AP "const char" ***argvPtr out \fI*argvPtr\fR will be filled in with the address of an array of pointers to the strings that are the extracted elements of \fIlist\fR. There will be \fI*argcPtr\fR valid entries in the array, followed by a NULL entry. .AP int argc in Number of elements in \fIargv\fR. -.AP char **argv in +.AP "const char *const" *argv in Array of strings to merge together into a single list. Each string will become a separate element of the list. -.AP char *src in +.AP "const char" *src in String that is to become an element of a list. .AP int *flagsPtr in Pointer to word to fill in with information about \fIsrc\fR. The value of *\fIflagsPtr\fR must be passed to \fBTcl_ConvertElement\fR. -.VS .AP int length in Number of bytes in string \fIsrc\fR. -.VE .AP char *dst in Place to copy converted list element. Must contain enough characters to hold converted string. @@ -75,7 +65,6 @@ Information about \fIsrc\fR. Must be value returned by previous call to \fBTcl_ScanElement\fR, possibly OR-ed with \fBTCL_DONT_USE_BRACES\fR. .BE - .SH DESCRIPTION .PP These procedures may be used to disassemble and reassemble Tcl lists. @@ -90,28 +79,27 @@ also holds copies of all the list elements. It is the caller's responsibility to free up all of this storage. For example, suppose that you have called \fBTcl_SplitList\fR with the following code: +.PP .CS int argc, code; char *string; char **argv; \&... -code = Tcl_SplitList(interp, string, &argc, &argv); +code = \fBTcl_SplitList\fR(interp, string, &argc, &argv); .CE +.PP Then you should eventually free the storage with a call like the following: -.VS +.PP .CS Tcl_Free((char *) argv); .CE -.VE .PP \fBTcl_SplitList\fR normally returns \fBTCL_OK\fR, which means the list was successfully parsed. If there was a syntax error in \fIlist\fR, then \fBTCL_ERROR\fR is returned -and \fIinterp->result\fR will point to an error message describing the -.VS +and the interpreter's result will point to an error message describing the problem (if \fIinterp\fR was not NULL). -.VE If \fBTCL_ERROR\fR is returned then no memory is allocated and \fI*argvPtr\fR is not modified. .PP @@ -126,11 +114,9 @@ it will be parsed into \fIargc\fR words whose values will be the same as the \fIargv\fR strings passed to \fBTcl_Merge\fR. \fBTcl_Merge\fR will modify the list elements with braces and/or backslashes in order to produce proper Tcl list structure. -.VS The result string is dynamically allocated using \fBTcl_Alloc\fR; the caller must eventually release the space using \fBTcl_Free\fR. -.VE .PP If the result of \fBTcl_Merge\fR is passed to \fBTcl_SplitList\fR, the elements returned by \fBTcl_SplitList\fR will be identical to @@ -167,7 +153,7 @@ include spaces between adjacent list elements. \fBTcl_ConvertElement\fR uses one of two different approaches to handle the special characters in \fIsrc\fR. Wherever possible, it handles special characters by surrounding the string with braces. -This produces clean-looking output, but can't be used in some situations, +This produces clean-looking output, but cannot be used in some situations, such as when \fIsrc\fR contains unmatched braces. In these situations, \fBTcl_ConvertElement\fR handles special characters by generating backslash sequences for them. @@ -180,12 +166,23 @@ used to generate a portion of an argument for a Tcl command. In this case, surrounding \fIsrc\fR with curly braces would cause the command not to be parsed correctly. .PP -.VS +By default, \fBTcl_ConvertElement\fR will use quoting in its output +to be sure the first character of an element is not the hash +character +.PQ # . +This is to be sure the first element of any list +passed to \fBeval\fR is not mis-parsed as the beginning of a comment. +When a list element is not the first element of a list, this quoting +is not necessary. When the caller can be sure that the element is +not the first element of a list, it can disable quoting of the leading +hash character by OR-ing the flag value returned by \fBTcl_ScanElement\fR +with \fBTCL_DONT_QUOTE_HASH\fR. +.PP \fBTcl_ScanCountedElement\fR and \fBTcl_ConvertCountedElement\fR are the same as \fBTcl_ScanElement\fR and \fBTcl_ConvertElement\fR, except the length of string \fIsrc\fR is specified by the \fIlength\fR argument, and the string may contain embedded nulls. -.VE - +.SH "SEE ALSO" +Tcl_ListObjGetElements(3) .SH KEYWORDS backslash, convert, element, list, merge, split, strings |
