[25] | 1 | '\" |
---|
| 2 | '\" Copyright (c) 2001 Donal K. Fellows |
---|
| 3 | '\" |
---|
| 4 | '\" See the file "license.terms" for information on usage and redistribution |
---|
| 5 | '\" of this file, and for a DISCLAIMER OF ALL WARRANTIES. |
---|
| 6 | '\" |
---|
| 7 | '\" RCS: @(#) $Id: SubstObj.3,v 1.7 2007/12/13 15:22:32 dgp Exp $ |
---|
| 8 | '\" |
---|
| 9 | .so man.macros |
---|
| 10 | .TH Tcl_SubstObj 3 8.4 Tcl "Tcl Library Procedures" |
---|
| 11 | .BS |
---|
| 12 | .SH NAME |
---|
| 13 | Tcl_SubstObj \- perform substitutions on Tcl objects |
---|
| 14 | .SH SYNOPSIS |
---|
| 15 | .nf |
---|
| 16 | \fB#include <tcl.h>\fR |
---|
| 17 | .sp |
---|
| 18 | Tcl_Obj * |
---|
| 19 | \fBTcl_SubstObj\fR(\fIinterp, objPtr, flags\fR) |
---|
| 20 | .SH ARGUMENTS |
---|
| 21 | .AS Tcl_Interp **termPtr |
---|
| 22 | .AP Tcl_Interp *interp in |
---|
| 23 | Interpreter in which to execute Tcl scripts and lookup variables. If |
---|
| 24 | an error occurs, the interpreter's result is modified to hold an error |
---|
| 25 | message. |
---|
| 26 | .AP Tcl_Obj *objPtr in |
---|
| 27 | A Tcl object containing the string to perform substitutions on. |
---|
| 28 | .AP int flags in |
---|
| 29 | ORed combination of flag bits that specify which substitutions to |
---|
| 30 | perform. The flags \fBTCL_SUBST_COMMANDS\fR, |
---|
| 31 | \fBTCL_SUBST_VARIABLES\fR and \fBTCL_SUBST_BACKSLASHES\fR are |
---|
| 32 | currently supported, and \fBTCL_SUBST_ALL\fR is provided as a |
---|
| 33 | convenience for the common case where all substitutions are desired. |
---|
| 34 | .BE |
---|
| 35 | .SH DESCRIPTION |
---|
| 36 | .PP |
---|
| 37 | The \fBTcl_SubstObj\fR function is used to perform substitutions on |
---|
| 38 | strings in the fashion of the \fBsubst\fR command. It gets the value |
---|
| 39 | of the string contained in \fIobjPtr\fR and scans it, copying |
---|
| 40 | characters and performing the chosen substitutions as it goes to an |
---|
| 41 | output object which is returned as the result of the function. In the |
---|
| 42 | event of an error occurring during the execution of a command or |
---|
| 43 | variable substitution, the function returns NULL and an error message |
---|
| 44 | is left in \fIinterp\fR's result. |
---|
| 45 | .PP |
---|
| 46 | Three kinds of substitutions are supported. When the |
---|
| 47 | \fBTCL_SUBST_BACKSLASHES\fR bit is set in \fIflags\fR, sequences that |
---|
| 48 | look like backslash substitutions for Tcl commands are replaced by |
---|
| 49 | their corresponding character. |
---|
| 50 | .PP |
---|
| 51 | When the \fBTCL_SUBST_VARIABLES\fR bit is set in \fIflags\fR, |
---|
| 52 | sequences that look like variable substitutions for Tcl commands are |
---|
| 53 | replaced by the contents of the named variable. |
---|
| 54 | .PP |
---|
| 55 | When the \fBTCL_SUBST_COMMANDS\fR bit is set in \fIflags\fR, sequences |
---|
| 56 | that look like command substitutions for Tcl commands are replaced by |
---|
| 57 | the result of evaluating that script. Where an uncaught |
---|
| 58 | .QW "continue exception" |
---|
| 59 | occurs during the evaluation of a command substitution, an |
---|
| 60 | empty string is substituted for the command. Where an uncaught |
---|
| 61 | .QW "break exception" |
---|
| 62 | occurs during the evaluation of a command substitution, the |
---|
| 63 | result of the whole substitution on \fIobjPtr\fR will be truncated at |
---|
| 64 | the point immediately before the start of the command substitution, |
---|
| 65 | and no characters will be added to the result or substitutions |
---|
| 66 | performed after that point. |
---|
| 67 | .SH "SEE ALSO" |
---|
| 68 | subst(n) |
---|
| 69 | .SH KEYWORDS |
---|
| 70 | backslash substitution, command substitution, variable substitution |
---|