OSDN Git Service

FIRST REPOSITORY
[eos/hostdependOTHERS.git] / ALPHALINUX5 / util / ALPHALINUX5 / man / man3 / Tcl_SplitList.3
1 '\"
2 '\" Copyright (c) 1989-1993 The Regents of the University of California.
3 '\" Copyright (c) 1994-1996 Sun Microsystems, Inc.
4 '\"
5 '\" See the file "license.terms" for information on usage and redistribution
6 '\" of this file, and for a DISCLAIMER OF ALL WARRANTIES.
7 '\" 
8 '\" RCS: @(#) $Id: SplitList.3,v 1.3 2000/04/14 23:01:53 hobbs Exp $
9 '\" 
10 '\" The definitions below are for supplemental macros used in Tcl/Tk
11 '\" manual entries.
12 '\"
13 '\" .AP type name in/out ?indent?
14 '\"     Start paragraph describing an argument to a library procedure.
15 '\"     type is type of argument (int, etc.), in/out is either "in", "out",
16 '\"     or "in/out" to describe whether procedure reads or modifies arg,
17 '\"     and indent is equivalent to second arg of .IP (shouldn't ever be
18 '\"     needed;  use .AS below instead)
19 '\"
20 '\" .AS ?type? ?name?
21 '\"     Give maximum sizes of arguments for setting tab stops.  Type and
22 '\"     name are examples of largest possible arguments that will be passed
23 '\"     to .AP later.  If args are omitted, default tab stops are used.
24 '\"
25 '\" .BS
26 '\"     Start box enclosure.  From here until next .BE, everything will be
27 '\"     enclosed in one large box.
28 '\"
29 '\" .BE
30 '\"     End of box enclosure.
31 '\"
32 '\" .CS
33 '\"     Begin code excerpt.
34 '\"
35 '\" .CE
36 '\"     End code excerpt.
37 '\"
38 '\" .VS ?version? ?br?
39 '\"     Begin vertical sidebar, for use in marking newly-changed parts
40 '\"     of man pages.  The first argument is ignored and used for recording
41 '\"     the version when the .VS was added, so that the sidebars can be
42 '\"     found and removed when they reach a certain age.  If another argument
43 '\"     is present, then a line break is forced before starting the sidebar.
44 '\"
45 '\" .VE
46 '\"     End of vertical sidebar.
47 '\"
48 '\" .DS
49 '\"     Begin an indented unfilled display.
50 '\"
51 '\" .DE
52 '\"     End of indented unfilled display.
53 '\"
54 '\" .SO
55 '\"     Start of list of standard options for a Tk widget.  The
56 '\"     options follow on successive lines, in four columns separated
57 '\"     by tabs.
58 '\"
59 '\" .SE
60 '\"     End of list of standard options for a Tk widget.
61 '\"
62 '\" .OP cmdName dbName dbClass
63 '\"     Start of description of a specific option.  cmdName gives the
64 '\"     option's name as specified in the class command, dbName gives
65 '\"     the option's name in the option database, and dbClass gives
66 '\"     the option's class in the option database.
67 '\"
68 '\" .UL arg1 arg2
69 '\"     Print arg1 underlined, then print arg2 normally.
70 '\"
71 '\" RCS: @(#) $Id: man.macros,v 1.3 1999/04/16 00:46:35 stanton Exp $
72 '\"
73 '\"     # Set up traps and other miscellaneous stuff for Tcl/Tk man pages.
74 .if t .wh -1.3i ^B
75 .nr ^l \n(.l
76 .ad b
77 '\"     # Start an argument description
78 .de AP
79 .ie !"\\$4"" .TP \\$4
80 .el \{\
81 .   ie !"\\$2"" .TP \\n()Cu
82 .   el          .TP 15
83 .\}
84 .ta \\n()Au \\n()Bu
85 .ie !"\\$3"" \{\
86 \&\\$1  \\fI\\$2\\fP    (\\$3)
87 .\".b
88 .\}
89 .el \{\
90 .br
91 .ie !"\\$2"" \{\
92 \&\\$1  \\fI\\$2\\fP
93 .\}
94 .el \{\
95 \&\\fI\\$1\\fP
96 .\}
97 .\}
98 ..
99 '\"     # define tabbing values for .AP
100 .de AS
101 .nr )A 10n
102 .if !"\\$1"" .nr )A \\w'\\$1'u+3n
103 .nr )B \\n()Au+15n
104 .\"
105 .if !"\\$2"" .nr )B \\w'\\$2'u+\\n()Au+3n
106 .nr )C \\n()Bu+\\w'(in/out)'u+2n
107 ..
108 .AS Tcl_Interp Tcl_CreateInterp in/out
109 '\"     # BS - start boxed text
110 '\"     # ^y = starting y location
111 '\"     # ^b = 1
112 .de BS
113 .br
114 .mk ^y
115 .nr ^b 1u
116 .if n .nf
117 .if n .ti 0
118 .if n \l'\\n(.lu\(ul'
119 .if n .fi
120 ..
121 '\"     # BE - end boxed text (draw box now)
122 .de BE
123 .nf
124 .ti 0
125 .mk ^t
126 .ie n \l'\\n(^lu\(ul'
127 .el \{\
128 .\"     Draw four-sided box normally, but don't draw top of
129 .\"     box if the box started on an earlier page.
130 .ie !\\n(^b-1 \{\
131 \h'-1.5n'\L'|\\n(^yu-1v'\l'\\n(^lu+3n\(ul'\L'\\n(^tu+1v-\\n(^yu'\l'|0u-1.5n\(ul'
132 .\}
133 .el \}\
134 \h'-1.5n'\L'|\\n(^yu-1v'\h'\\n(^lu+3n'\L'\\n(^tu+1v-\\n(^yu'\l'|0u-1.5n\(ul'
135 .\}
136 .\}
137 .fi
138 .br
139 .nr ^b 0
140 ..
141 '\"     # VS - start vertical sidebar
142 '\"     # ^Y = starting y location
143 '\"     # ^v = 1 (for troff;  for nroff this doesn't matter)
144 .de VS
145 .if !"\\$2"" .br
146 .mk ^Y
147 .ie n 'mc \s12\(br\s0
148 .el .nr ^v 1u
149 ..
150 '\"     # VE - end of vertical sidebar
151 .de VE
152 .ie n 'mc
153 .el \{\
154 .ev 2
155 .nf
156 .ti 0
157 .mk ^t
158 \h'|\\n(^lu+3n'\L'|\\n(^Yu-1v\(bv'\v'\\n(^tu+1v-\\n(^Yu'\h'-|\\n(^lu+3n'
159 .sp -1
160 .fi
161 .ev
162 .\}
163 .nr ^v 0
164 ..
165 '\"     # Special macro to handle page bottom:  finish off current
166 '\"     # box/sidebar if in box/sidebar mode, then invoked standard
167 '\"     # page bottom macro.
168 .de ^B
169 .ev 2
170 'ti 0
171 'nf
172 .mk ^t
173 .if \\n(^b \{\
174 .\"     Draw three-sided box if this is the box's first page,
175 .\"     draw two sides but no top otherwise.
176 .ie !\\n(^b-1 \h'-1.5n'\L'|\\n(^yu-1v'\l'\\n(^lu+3n\(ul'\L'\\n(^tu+1v-\\n(^yu'\h'|0u'\c
177 .el \h'-1.5n'\L'|\\n(^yu-1v'\h'\\n(^lu+3n'\L'\\n(^tu+1v-\\n(^yu'\h'|0u'\c
178 .\}
179 .if \\n(^v \{\
180 .nr ^x \\n(^tu+1v-\\n(^Yu
181 \kx\h'-\\nxu'\h'|\\n(^lu+3n'\ky\L'-\\n(^xu'\v'\\n(^xu'\h'|0u'\c
182 .\}
183 .bp
184 'fi
185 .ev
186 .if \\n(^b \{\
187 .mk ^y
188 .nr ^b 2
189 .\}
190 .if \\n(^v \{\
191 .mk ^Y
192 .\}
193 ..
194 '\"     # DS - begin display
195 .de DS
196 .RS
197 .nf
198 .sp
199 ..
200 '\"     # DE - end display
201 .de DE
202 .fi
203 .RE
204 .sp
205 ..
206 '\"     # SO - start of list of standard options
207 .de SO
208 .SH "STANDARD OPTIONS"
209 .LP
210 .nf
211 .ta 4c 8c 12c
212 .ft B
213 ..
214 '\"     # SE - end of list of standard options
215 .de SE
216 .fi
217 .ft R
218 .LP
219 See the \\fBoptions\\fR manual entry for details on the standard options.
220 ..
221 '\"     # OP - start of full description for a single option
222 .de OP
223 .LP
224 .nf
225 .ta 4c
226 Command-Line Name:      \\fB\\$1\\fR
227 Database Name:  \\fB\\$2\\fR
228 Database Class: \\fB\\$3\\fR
229 .fi
230 .IP
231 ..
232 '\"     # CS - begin code excerpt
233 .de CS
234 .RS
235 .nf
236 .ta .25i .5i .75i 1i
237 ..
238 '\"     # CE - end code excerpt
239 .de CE
240 .fi
241 .RE
242 ..
243 .de UL
244 \\$1\l'|0\(ul'\\$2
245 ..
246 .TH Tcl_SplitList 3 8.0 Tcl "Tcl Library Procedures"
247 .BS
248 .SH NAME
249 Tcl_SplitList, Tcl_Merge, Tcl_ScanElement, Tcl_ConvertElement \- manipulate Tcl lists
250 .SH SYNOPSIS
251 .nf
252 \fB#include <tcl.h>\fR
253 .sp
254 int
255 \fBTcl_SplitList\fR(\fIinterp, list, argcPtr, argvPtr\fR)
256 .sp
257 char *
258 \fBTcl_Merge\fR(\fIargc, argv\fR)
259 .sp
260 int
261 \fBTcl_ScanElement\fR(\fIsrc, flagsPtr\fR)
262 .sp
263 int
264 \fBTcl_ScanCountedElement\fR(\fIsrc, length, flagsPtr\fR)
265 .sp
266 int
267 \fBTcl_ConvertElement\fR(\fIsrc, dst, flags\fR)
268 .sp
269 int
270 \fBTcl_ConvertCountedElement\fR(\fIsrc, length, dst, flags\fR)
271 .SH ARGUMENTS
272 .AS Tcl_Interp ***argvPtr
273 .AP Tcl_Interp *interp out
274 Interpreter to use for error reporting.  If NULL, then no error message
275 is left.
276 .AP char *list in
277 Pointer to a string with proper list structure.
278 .AP int *argcPtr out
279 Filled in with number of elements in \fIlist\fR.
280 .AP char ***argvPtr out
281 \fI*argvPtr\fR will be filled in with the address of an array of
282 pointers to the strings that are the extracted elements of \fIlist\fR.
283 There will be \fI*argcPtr\fR valid entries in the array, followed by
284 a NULL entry.
285 .AP int argc in
286 Number of elements in \fIargv\fR.
287 .AP char **argv in
288 Array of strings to merge together into a single list.
289 Each string will become a separate element of the list.
290 .AP char *src in
291 String that is to become an element of a list.
292 .AP int *flagsPtr in
293 Pointer to word to fill in with information about \fIsrc\fR.
294 The value of *\fIflagsPtr\fR must be passed to \fBTcl_ConvertElement\fR.
295 .AP int length in
296 Number of bytes in string \fIsrc\fR.
297 .AP char *dst in
298 Place to copy converted list element.  Must contain enough characters
299 to hold converted string.
300 .AP int flags in
301 Information about \fIsrc\fR. Must be value returned by previous
302 call to \fBTcl_ScanElement\fR, possibly OR-ed
303 with \fBTCL_DONT_USE_BRACES\fR.
304 .BE
305
306 .SH DESCRIPTION
307 .PP
308 These procedures may be used to disassemble and reassemble Tcl lists.
309 \fBTcl_SplitList\fR breaks a list up into its constituent elements,
310 returning an array of pointers to the elements using
311 \fIargcPtr\fR and \fIargvPtr\fR.
312 While extracting the arguments, \fBTcl_SplitList\fR obeys the usual
313 rules for backslash substitutions and braces.  The area of
314 memory pointed to by \fI*argvPtr\fR is dynamically allocated;  in
315 addition to the array of pointers, it
316 also holds copies of all the list elements.  It is the caller's
317 responsibility to free up all of this storage.
318 For example, suppose that you have called \fBTcl_SplitList\fR with
319 the following code:
320 .CS
321 int argc, code;
322 char *string;
323 char **argv;
324 \&...
325 code = Tcl_SplitList(interp, string, &argc, &argv);
326 .CE
327 Then you should eventually free the storage with a call like the
328 following:
329 .CS
330 Tcl_Free((char *) argv);
331 .CE
332 .PP
333 \fBTcl_SplitList\fR normally returns \fBTCL_OK\fR, which means the list was
334 successfully parsed.
335 If there was a syntax error in \fIlist\fR, then \fBTCL_ERROR\fR is returned
336 and the interpreter's result will point to an error message describing the
337 problem (if \fIinterp\fR was not NULL).
338 If \fBTCL_ERROR\fR is returned then no memory is allocated and \fI*argvPtr\fR
339 is not modified.
340 .PP
341 \fBTcl_Merge\fR is the inverse of \fBTcl_SplitList\fR:  it
342 takes a collection of strings given by \fIargc\fR
343 and \fIargv\fR and generates a result string
344 that has proper list structure.
345 This means that commands like \fBindex\fR may be used to
346 extract the original elements again.
347 In addition, if the result of \fBTcl_Merge\fR is passed to \fBTcl_Eval\fR,
348 it will be parsed into \fIargc\fR words whose values will
349 be the same as the \fIargv\fR strings passed to \fBTcl_Merge\fR.
350 \fBTcl_Merge\fR will modify the list elements with braces and/or
351 backslashes in order to produce proper Tcl list structure.
352 The result string is dynamically allocated
353 using \fBTcl_Alloc\fR;  the caller must eventually release the space
354 using \fBTcl_Free\fR.
355 .PP
356 If the result of \fBTcl_Merge\fR is passed to \fBTcl_SplitList\fR,
357 the elements returned by \fBTcl_SplitList\fR will be identical to
358 those passed into \fBTcl_Merge\fR.
359 However, the converse is not true:  if \fBTcl_SplitList\fR
360 is passed a given string, and the resulting \fIargc\fR and
361 \fIargv\fR are passed to \fBTcl_Merge\fR, the resulting string
362 may not be the same as the original string passed to \fBTcl_SplitList\fR.
363 This is because \fBTcl_Merge\fR may use backslashes and braces
364 differently than the original string.
365 .PP
366 \fBTcl_ScanElement\fR and \fBTcl_ConvertElement\fR are the
367 procedures that do all of the real work of \fBTcl_Merge\fR.
368 \fBTcl_ScanElement\fR scans its \fIsrc\fR argument
369 and determines how to use backslashes and braces
370 when converting it to a list element.
371 It returns an overestimate of the number of characters
372 required to represent \fIsrc\fR as a list element, and
373 it stores information in \fI*flagsPtr\fR that is needed
374 by \fBTcl_ConvertElement\fR.
375 .PP
376 \fBTcl_ConvertElement\fR is a companion procedure to \fBTcl_ScanElement\fR.
377 It does the actual work of converting a string to a list element.
378 Its \fIflags\fR argument must be the same as the value returned
379 by \fBTcl_ScanElement\fR.
380 \fBTcl_ConvertElement\fR writes a proper list element to memory
381 starting at *\fIdst\fR and returns a count of the total number
382 of characters written, which will be no more than the result
383 returned by \fBTcl_ScanElement\fR.
384 \fBTcl_ConvertElement\fR writes out only the actual list element
385 without any leading or trailing spaces: it is up to the caller to
386 include spaces between adjacent list elements.
387 .PP
388 \fBTcl_ConvertElement\fR uses one of two different approaches to
389 handle the special characters in \fIsrc\fR.  Wherever possible, it
390 handles special characters by surrounding the string with braces.
391 This produces clean-looking output, but can't be used in some situations,
392 such as when \fIsrc\fR contains unmatched braces.
393 In these situations, \fBTcl_ConvertElement\fR handles special
394 characters by generating backslash sequences for them.
395 The caller may insist on the second approach by OR-ing the
396 flag value returned by \fBTcl_ScanElement\fR with
397 \fBTCL_DONT_USE_BRACES\fR.
398 Although this will produce an uglier result, it is useful in some
399 special situations, such as when \fBTcl_ConvertElement\fR is being
400 used to generate a portion of an argument for a Tcl command.
401 In this case, surrounding \fIsrc\fR with curly braces would cause
402 the command not to be parsed correctly.
403 .PP
404 \fBTcl_ScanCountedElement\fR and \fBTcl_ConvertCountedElement\fR are
405 the same as \fBTcl_ScanElement\fR and \fBTcl_ConvertElement\fR, except
406 the length of string \fIsrc\fR is specified by the \fIlength\fR
407 argument, and the string may contain embedded nulls.
408
409 .SH KEYWORDS
410 backslash, convert, element, list, merge, split, strings