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