Tcl Library Source Code

Check-in [b062daa852]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Merged trunk bug fixes into RC.
Downloads: Tarball | ZIP archive
Timelines: family | ancestors | descendants | both | tcllib-1-16-rc
Files: files | file ages | folders
SHA1: b062daa852277dfeead33b5580de8c5082c5bb45
User & Date: aku 2014-01-23 06:41:24.220
Context
2014-01-23
19:10
Update RC with latest fixes. check-in: 10b275b56b user: andreask tags: tcllib-1-16-rc
06:41
Merged trunk bug fixes into RC. check-in: b062daa852 user: aku tags: tcllib-1-16-rc
06:38
[Ticket 30be135c2a]: Added command 'capEachWord'. Bumped package version to 0.8. Extended testsuite. check-in: 569eb15c5b user: aku tags: trunk
2014-01-21
19:36
Merged trunk doc changes into RC check-in: a4ee06a044 user: aku tags: tcllib-1-16-rc
Changes
Unified Diff Ignore Whitespace Patch
Changes to apps/pt.
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
    return $res
}

# # ## ### ##### ######## ############# #####################

proc ::pt::app::generateHelp {} {
    return {
	@ generate PFORMAT PFILE ?-option value...? INFORMAT GFILE

	Generate data in format PFORMAT and write it to PFILE.  Read
	the grammar to be processed from GFILE (assuming the format
	GFORMAT). Use any options to configure the generator. The are
	dependent on PFORMAT.
    }
}







|







90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
    return $res
}

# # ## ### ##### ######## ############# #####################

proc ::pt::app::generateHelp {} {
    return {
	@ generate PFORMAT ?-option value...? PFILE INFORMAT GFILE

	Generate data in format PFORMAT and write it to PFILE.  Read
	the grammar to be processed from GFILE (assuming the format
	GFORMAT). Use any options to configure the generator. The are
	dependent on PFORMAT.
    }
}
Changes to modules/pt/ChangeLog.









1
2
3
4
5
6
7









2013-12-17  Andreas Kupries <[email protected]>

	* pt_parse_peg.man: Added missing documentation for the PEG parser
	  package.
	* pt_peg_op.man: Added missing documentation for this utility package.
	* pt_peg_op.tcl: Exported 'minimize'.

>
>
>
>
>
>
>
>
>







1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
2014-01-22  Andreas Kupries  <aku@hephaistos>

	* pt_pgen.tcl Ticket [1b7fe4fe19]: Fixed missing class/package
	* pt_pgen.man: initialization for critcl generator. Bumped
	* pkgIndex.tcl: package version to 1.0.2

	* ../../apps/pt Ticket [c3ab006ca2]: Fixed help delivered by the
	  'pt' application.

2013-12-17  Andreas Kupries <[email protected]>

	* pt_parse_peg.man: Added missing documentation for the PEG parser
	  package.
	* pt_peg_op.man: Added missing documentation for this utility package.
	* pt_peg_op.tcl: Exported 'minimize'.

Changes to modules/pt/pkgIndex.tcl.
55
56
57
58
59
60
61
62

# */PARAM support (canned configurations).
package ifneeded pt::cparam::configuration::critcl  1.0.1 [list source [file join $dir pt_cparam_config_critcl.tcl]]
package ifneeded pt::tclparam::configuration::snit  1.0.1 [list source [file join $dir pt_tclparam_config_snit.tcl]]
package ifneeded pt::tclparam::configuration::tcloo 1.0.3 [list source [file join $dir pt_tclparam_config_tcloo.tcl]]

# Parser generator core.
package ifneeded pt::pgen 1.0.1 [list source [file join $dir pt_pgen.tcl]]







|
55
56
57
58
59
60
61
62

# */PARAM support (canned configurations).
package ifneeded pt::cparam::configuration::critcl  1.0.1 [list source [file join $dir pt_cparam_config_critcl.tcl]]
package ifneeded pt::tclparam::configuration::snit  1.0.1 [list source [file join $dir pt_tclparam_config_snit.tcl]]
package ifneeded pt::tclparam::configuration::tcloo 1.0.3 [list source [file join $dir pt_tclparam_config_tcloo.tcl]]

# Parser generator core.
package ifneeded pt::pgen 1.0.2 [list source [file join $dir pt_pgen.tcl]]
Changes to modules/pt/pt_pgen.man.
1

2
3
4
5
6
7
8
9
10
11
12
[comment {-*- text -*- doctools manpage}]

[manpage_begin pt::pgen n 1.0.1]
[include include/module.inc]
[titledesc {Parser Generator}]
[require pt::pgen [opt 1.0.1]]
[description]
[include include/ref_intro.inc]

This package provides a command implementing a
[term {parser generator}]
taking parsing expression grammars as input.


>
|


|







1
2
3
4
5
6
7
8
9
10
11
12
13
[comment {-*- text -*- doctools manpage}]
[vset PGEN_VERSION 1.0.2]
[manpage_begin pt::pgen n [vset PGEN_VERSION]]
[include include/module.inc]
[titledesc {Parser Generator}]
[require pt::pgen [opt [vset PGEN_VERSION]]]
[description]
[include include/ref_intro.inc]

This package provides a command implementing a
[term {parser generator}]
taking parsing expression grammars as input.

Changes to modules/pt/pt_pgen.tcl.
108
109
110
111
112
113
114

115
116
117
118
119
120
121
}

proc ::pt::pgen::Write::critcl {args} {
    # args = (option value)... grammar
    # Class   -> touches/defines variable 'class'
    # Package -> touches/defines variable 'package'
    pt::peg::to::cparam configure {*}[Package [Class [lrange $args 0 end-1]]]


    pt::cparam::configuration::critcl def \
	$class $package \
	{pt::peg::to::cparam configure}

    return [pt::peg::to::cparam convert [lindex $args end]]
}







>







108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
}

proc ::pt::pgen::Write::critcl {args} {
    # args = (option value)... grammar
    # Class   -> touches/defines variable 'class'
    # Package -> touches/defines variable 'package'
    pt::peg::to::cparam configure {*}[Package [Class [lrange $args 0 end-1]]]
    ClassPackageDefaults

    pt::cparam::configuration::critcl def \
	$class $package \
	{pt::peg::to::cparam configure}

    return [pt::peg::to::cparam convert [lindex $args end]]
}
173
174
175
176
177
178
179
180
    }
    return $res
}

# ### ### ### ######### ######### #########
## Package Management

package provide pt::pgen 1.0.1







|
174
175
176
177
178
179
180
181
    }
    return $res
}

# ### ### ### ######### ######### #########
## Package Management

package provide pt::pgen 1.0.2
Changes to modules/textutil/ChangeLog.









1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112









2013-12-06  Andreas Kupries  <[email protected]>

	* expander.man: Ticket [01afa9345d]. Added note about method
	  'expand' pushing a new and empty context while running.

2013-10-28  Andreas Kupries  <[email protected]>

	* expander.man: Ticket [e65df22e92]. Fixed typos.

2013-02-01  Andreas Kupries  <[email protected]>

	*
	* Released and tagged Tcllib 1.15 ========================
	* 

2011-12-13  Andreas Kupries  <[email protected]>

	*
	* Released and tagged Tcllib 1.14 ========================
	* 

2011-12-13  Andreas Kupries  <aku@hephaistos>

	* adjust.tcl (::textutil::adjust::undent): Fixed whitespace regexp
	* adjust.man: which lost the tab character. Rewritten to make it
	* pkgIndex.tcl: less likely to happen again. Bumped to 0.7.1.

2011-01-24  Andreas Kupries  <[email protected]>

	*
	* Released and tagged Tcllib 1.13 ========================
	* 

2009-12-07  Andreas Kupries  <[email protected]>

	*
	* Released and tagged Tcllib 1.12 ========================
	* 

2008-12-12  Andreas Kupries  <[email protected]>

	*
	* Released and tagged Tcllib 1.11.1 ========================
	* 

2008-10-16  Andreas Kupries  <[email protected]>

	*
	* Released and tagged Tcllib 1.11 ========================
	* 

2008-10-10  Andreas Kupries  <[email protected]>

	* string.man: Renamed to textutil_string.man. Avoid clash with core.
	* split.man:  Renamed to textutil_split.man. Avoid clash with core.
	  Fix [Bug 2124508].

2008-06-12  Andreas Kupries  <[email protected]>

	* textutil_adjust.pcx: New file. Syntax definitions for the public
	* textutil_repeat.pcx: commands of the textutil packages.
	* textutil_split.pcx:
	* textutil_string.pcx:
	* textutil_tabify.pcx:
	* textutil_trim.pcx:

2008-03-22  Michael Schlenker <[email protected]>

        * string.tcl:   Faster longestCommonPrefixList proc
	* string.bench: Bench file for ::textutil::string package
	* string.man: 
        * pkgIndex.tcl: subpackage version to 0.7.1

2008-03-17  Andreas Kupries  <[email protected]>

	* adjust.man: Added documentation for the packages the
	* repeat.man: textutil bundle consists of.
	* split.man:
	* string.man:
	* tabify.man:
	* trim.man:
	* textutil.man: Noted that the bundle package is now deprecated
	  and will go away in the future.

2007-09-12  Andreas Kupries  <[email protected]>

	*
	* Released and tagged Tcllib 1.10 ========================
	* 

2007-03-21  Andreas Kupries  <[email protected]>

	* textutil.man: Fixed all warnings due to use of now deprecated
	* expander.man: commands. Added a section about how to give feedback.

2006-10-03  Andreas Kupries  <[email protected]>

	*
	* Released and tagged Tcllib 1.9 ========================
	* 

2006-09-20  Andreas Kupries  <[email protected]>

	* textutil.tcl: Bumped version to 0.7.1
	* textutil.man: 
	* pkgIndex.tcl:

2006-09-19  Andreas Kupries  <[email protected]>

	* expander.man: Bumped version to 1.3.1
	* expander.tcl:
	* pkgIndex.tcl:
>
>
>
>
>
>
>
>
>













|





|











|





|





|





|




















|

















|










|




|







1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
2014-01-22  Andreas Kupries  <aku@hephaistos>

	* pkgIndex.tcl [Ticket 30be135c2a]: Added command 'capEachWord'.
	* string.tcl: Bumped package version to 0.8. Extended testsuite.
	* textutil_string.man:
	* textutil.test:
	* textutil.tcl:
	* textutil.man:

2013-12-06  Andreas Kupries  <[email protected]>

	* expander.man: Ticket [01afa9345d]. Added note about method
	  'expand' pushing a new and empty context while running.

2013-10-28  Andreas Kupries  <[email protected]>

	* expander.man: Ticket [e65df22e92]. Fixed typos.

2013-02-01  Andreas Kupries  <[email protected]>

	*
	* Released and tagged Tcllib 1.15 ========================
	*

2011-12-13  Andreas Kupries  <[email protected]>

	*
	* Released and tagged Tcllib 1.14 ========================
	*

2011-12-13  Andreas Kupries  <aku@hephaistos>

	* adjust.tcl (::textutil::adjust::undent): Fixed whitespace regexp
	* adjust.man: which lost the tab character. Rewritten to make it
	* pkgIndex.tcl: less likely to happen again. Bumped to 0.7.1.

2011-01-24  Andreas Kupries  <[email protected]>

	*
	* Released and tagged Tcllib 1.13 ========================
	*

2009-12-07  Andreas Kupries  <[email protected]>

	*
	* Released and tagged Tcllib 1.12 ========================
	*

2008-12-12  Andreas Kupries  <[email protected]>

	*
	* Released and tagged Tcllib 1.11.1 ========================
	*

2008-10-16  Andreas Kupries  <[email protected]>

	*
	* Released and tagged Tcllib 1.11 ========================
	*

2008-10-10  Andreas Kupries  <[email protected]>

	* string.man: Renamed to textutil_string.man. Avoid clash with core.
	* split.man:  Renamed to textutil_split.man. Avoid clash with core.
	  Fix [Bug 2124508].

2008-06-12  Andreas Kupries  <[email protected]>

	* textutil_adjust.pcx: New file. Syntax definitions for the public
	* textutil_repeat.pcx: commands of the textutil packages.
	* textutil_split.pcx:
	* textutil_string.pcx:
	* textutil_tabify.pcx:
	* textutil_trim.pcx:

2008-03-22  Michael Schlenker <[email protected]>

        * string.tcl:   Faster longestCommonPrefixList proc
	* string.bench: Bench file for ::textutil::string package
	* string.man:
        * pkgIndex.tcl: subpackage version to 0.7.1

2008-03-17  Andreas Kupries  <[email protected]>

	* adjust.man: Added documentation for the packages the
	* repeat.man: textutil bundle consists of.
	* split.man:
	* string.man:
	* tabify.man:
	* trim.man:
	* textutil.man: Noted that the bundle package is now deprecated
	  and will go away in the future.

2007-09-12  Andreas Kupries  <[email protected]>

	*
	* Released and tagged Tcllib 1.10 ========================
	*

2007-03-21  Andreas Kupries  <[email protected]>

	* textutil.man: Fixed all warnings due to use of now deprecated
	* expander.man: commands. Added a section about how to give feedback.

2006-10-03  Andreas Kupries  <[email protected]>

	*
	* Released and tagged Tcllib 1.9 ========================
	*

2006-09-20  Andreas Kupries  <[email protected]>

	* textutil.tcl: Bumped version to 0.7.1
	* textutil.man:
	* pkgIndex.tcl:

2006-09-19  Andreas Kupries  <[email protected]>

	* expander.man: Bumped version to 1.3.1
	* expander.tcl:
	* pkgIndex.tcl:
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
	* tabify.test:
	* texttutil.test:
	* trim.test:

2006-01-28  Andreas Kupries  <[email protected]>

	* expander.test: Fixed duplicate usage of test names.
	* textutil.test: 

2006-01-26  Andreas Kupries  <[email protected]>

	* adjust.test: More boilerplate simplified via use of test support.
	* adjust_hyph.test:
	* expander.test:
	* repeat.test:







|







148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
	* tabify.test:
	* texttutil.test:
	* trim.test:

2006-01-28  Andreas Kupries  <[email protected]>

	* expander.test: Fixed duplicate usage of test names.
	* textutil.test:

2006-01-26  Andreas Kupries  <[email protected]>

	* adjust.test: More boilerplate simplified via use of test support.
	* adjust_hyph.test:
	* expander.test:
	* repeat.test:
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
	* expander.test: Modified an existing test to fail for the
	  original error, it does not anymore with the fix applied.

2005-10-06  Andreas Kupries  <[email protected]>

	*
	* Released and tagged Tcllib 1.8 ========================
	* 

2005-04-26  Andreas Kupries  <[email protected]>

	* adjust.tcl (indent): Fixed bug in handling of leading
	  whitespace. We must not remove it before indentation. We can
	  remove only trailing whitespace (text, and per line). Did a
	  little micro-optimization to reduce the size of the bytecode.







|







186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
	* expander.test: Modified an existing test to fail for the
	  original error, it does not anymore with the fix applied.

2005-10-06  Andreas Kupries  <[email protected]>

	*
	* Released and tagged Tcllib 1.8 ========================
	*

2005-04-26  Andreas Kupries  <[email protected]>

	* adjust.tcl (indent): Fixed bug in handling of leading
	  whitespace. We must not remove it before indentation. We can
	  remove only trailing whitespace (text, and per line). Did a
	  little micro-optimization to reduce the size of the bytecode.
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
	* textutil.man: been extended as well, and the documentation
	  too.

2004-10-05  Andreas Kupries  <[email protected]>

	*
	* Released and tagged Tcllib 1.7 ========================
	* 

2004-07-28  Andreas Kupries  <[email protected]>

	* expander.tcl (LocUpdate): 'regexp -all' is 8.4'ism, and this
	  package is for 8.2/3 as well. Replaced with a x-version
	  construct.








|







209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
	* textutil.man: been extended as well, and the documentation
	  too.

2004-10-05  Andreas Kupries  <[email protected]>

	*
	* Released and tagged Tcllib 1.7 ========================
	*

2004-07-28  Andreas Kupries  <[email protected]>

	* expander.tcl (LocUpdate): 'regexp -all' is 8.4'ism, and this
	  package is for 8.2/3 as well. Replaced with a x-version
	  construct.

248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
	* textutil.man: release.
	* pkgIndex.tcl:

2004-05-23  Andreas Kupries  <[email protected]>

	*
	* Released and tagged Tcllib 1.6.1 ========================
	* 

2004-05-23  Andreas Kupries  <[email protected]>

	* textutil.tcl: Rel. engineering. Updated version number 
	* textutil.man: of fileutil to reflect its changes, to 0.6.1.
	* pkgIndex.tcl:

2004-05-14  Andreas Kupries  <[email protected]>

	* adjust.tcl: The last commit of this file, not recorded in here
	  the ChangeLog :(, not only fixed the bug with the infinite loop







|



|







257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
	* textutil.man: release.
	* pkgIndex.tcl:

2004-05-23  Andreas Kupries  <[email protected]>

	*
	* Released and tagged Tcllib 1.6.1 ========================
	*

2004-05-23  Andreas Kupries  <[email protected]>

	* textutil.tcl: Rel. engineering. Updated version number
	* textutil.man: of fileutil to reflect its changes, to 0.6.1.
	* pkgIndex.tcl:

2004-05-14  Andreas Kupries  <[email protected]>

	* adjust.tcl: The last commit of this file, not recorded in here
	  the ChangeLog :(, not only fixed the bug with the infinite loop
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
	  fails. Using the CVS Head (== Tcllib 1.6) the reported problem
	  could not be reproduced. IOW this problem has been fixed already.

2004-02-15  Andreas Kupries  <[email protected]>

	*
	* Released and tagged Tcllib 1.6 ========================
	* 

2004-02-01  Johannes-Heinrich Vogeler <[email protected]>

        * fixed bug 860753 (plain justification does not work with
          hyphenation). Modified ::textutil::adjust::Justification

2003-08-06  Andreas Kupries  <[email protected]>







|







295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
	  fails. Using the CVS Head (== Tcllib 1.6) the reported problem
	  could not be reproduced. IOW this problem has been fixed already.

2004-02-15  Andreas Kupries  <[email protected]>

	*
	* Released and tagged Tcllib 1.6 ========================
	*

2004-02-01  Johannes-Heinrich Vogeler <[email protected]>

        * fixed bug 860753 (plain justification does not work with
          hyphenation). Modified ::textutil::adjust::Justification

2003-08-06  Andreas Kupries  <[email protected]>
Changes to modules/textutil/pkgIndex.tcl.
1
2
3
4
5
6
7
8
9
10
11
12
if {![package vsatisfies [package provide Tcl] 8.2]} {
    # FRINK: nocheck
    return
}
package ifneeded textutil           0.7.1 [list source [file join $dir textutil.tcl]]
package ifneeded textutil::adjust   0.7.1 [list source [file join $dir adjust.tcl]]
package ifneeded textutil::split    0.7 [list source [file join $dir split.tcl]]
package ifneeded textutil::trim     0.7 [list source [file join $dir trim.tcl]]
package ifneeded textutil::tabify   0.7 [list source [file join $dir tabify.tcl]]
package ifneeded textutil::repeat   0.7 [list source [file join $dir repeat.tcl]]
package ifneeded textutil::string   0.7.1 [list source [file join $dir string.tcl]]
package ifneeded textutil::expander 1.3.1 [list source [file join $dir expander.tcl]]




|

|
|
|
|
|

1
2
3
4
5
6
7
8
9
10
11
12
if {![package vsatisfies [package provide Tcl] 8.2]} {
    # FRINK: nocheck
    return
}
package ifneeded textutil           0.8   [list source [file join $dir textutil.tcl]]
package ifneeded textutil::adjust   0.7.1 [list source [file join $dir adjust.tcl]]
package ifneeded textutil::split    0.7   [list source [file join $dir split.tcl]]
package ifneeded textutil::trim     0.7   [list source [file join $dir trim.tcl]]
package ifneeded textutil::tabify   0.7   [list source [file join $dir tabify.tcl]]
package ifneeded textutil::repeat   0.7   [list source [file join $dir repeat.tcl]]
package ifneeded textutil::string   0.8   [list source [file join $dir string.tcl]]
package ifneeded textutil::expander 1.3.1 [list source [file join $dir expander.tcl]]
Changes to modules/textutil/string.tcl.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
# string.tcl --
#
#	Utilities for manipulating strings, words, single lines,
#	paragraphs, ...
#
# Copyright (c) 2000      by Ajuba Solutions.
# Copyright (c) 2000      by Eric Melski <[email protected]>
# Copyright (c) 2002      by Joe English <[email protected]>
# Copyright (c) 2001-2006 by Andreas Kupries <[email protected]>
#
# See the file "license.terms" for information on usage and redistribution
# of this file, and for a DISCLAIMER OF ALL WARRANTIES.
# 
# RCS: @(#) $Id: string.tcl,v 1.2 2008/03/22 16:03:11 mic42 Exp $

# ### ### ### ######### ######### #########








|







1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
# string.tcl --
#
#	Utilities for manipulating strings, words, single lines,
#	paragraphs, ...
#
# Copyright (c) 2000      by Ajuba Solutions.
# Copyright (c) 2000      by Eric Melski <[email protected]>
# Copyright (c) 2002      by Joe English <[email protected]>
# Copyright (c) 2001-2014 by Andreas Kupries <[email protected]>
#
# See the file "license.terms" for information on usage and redistribution
# of this file, and for a DISCLAIMER OF ALL WARRANTIES.
# 
# RCS: @(#) $Id: string.tcl,v 1.2 2008/03/22 16:03:11 mic42 Exp $

# ### ### ### ######### ######### #########
69
70
71
72
73
74
75













76
77
78
79
80
81
82
# @r The <a string> with its first character uncapitalized.
#
# @i uncapitalize

proc ::textutil::string::uncap {string} {
    return [string tolower [string index $string 0]][string range $string 1 end]
}














# Compute the longest string which is common to all strings given to
# the command, and at the beginning of said strings, i.e. a prefix. If
# only one argument is specified it is treated as a list of the
# strings to look at. If more than one argument is specified these
# arguments are the strings to be looked at. If only one string is
# given, in either form, the string is returned, as it is its own







>
>
>
>
>
>
>
>
>
>
>
>
>







69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
# @r The <a string> with its first character uncapitalized.
#
# @i uncapitalize

proc ::textutil::string::uncap {string} {
    return [string tolower [string index $string 0]][string range $string 1 end]
}

# @c Capitalizes first character of each word of the given <a sentence>.
#
# @a sentence: string to manipulate.
#
# @r The <a sentence> with the first character of each word capitalized.
#
# @i capitalize

proc ::textutil::string::capEachWord {sentence} {
    regsub -all {\S+} [string map {\\ \\\\ \$ \\$} $sentence] {[string toupper [string index & 0]][string range & 1 end]} cmd
    return [subst -nobackslashes -novariables $cmd]
}

# Compute the longest string which is common to all strings given to
# the command, and at the beginning of said strings, i.e. a prefix. If
# only one argument is specified it is treated as a list of the
# strings to look at. If more than one argument is specified these
# arguments are the strings to be looked at. If only one string is
# given, in either form, the string is returned, as it is its own
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131

# ### ### ### ######### ######### #########
## Data structures

namespace eval ::textutil::string {
    # Export the imported commands

    namespace export chop tail cap uncap
    namespace export longestCommonPrefix
    namespace export longestCommonPrefixList
}

# ### ### ### ######### ######### #########
## Ready

package provide textutil::string 0.7.1







|







|
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144

# ### ### ### ######### ######### #########
## Data structures

namespace eval ::textutil::string {
    # Export the imported commands

    namespace export chop tail cap uncap capEachWord
    namespace export longestCommonPrefix
    namespace export longestCommonPrefixList
}

# ### ### ### ######### ######### #########
## Ready

package provide textutil::string 0.8
Changes to modules/textutil/textutil.man.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
[manpage_begin textutil n 0.7.1]
[see_also regexp(n)]
[see_also split(n)]
[see_also string(n)]
[keywords formatting]
[keywords hyphenation]
[keywords indenting]
[keywords paragraph]
[keywords {regular expression}]
[keywords string]
[keywords TeX]
[keywords trimming]
[moddesc   {Text and string utilities, macro processing}]
[titledesc {Procedures to manipulate texts and strings.}]
[category  {Text processing}]
[require Tcl 8.2]
[require textutil [opt 0.7.1]]
[description]

The package [package textutil] provides commands that manipulate
strings or texts (a.k.a. long strings or string with embedded newlines
or paragraphs).

It is actually a bundle providing the commands of the six packages
|















|







1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
[manpage_begin textutil n 0.8]
[see_also regexp(n)]
[see_also split(n)]
[see_also string(n)]
[keywords formatting]
[keywords hyphenation]
[keywords indenting]
[keywords paragraph]
[keywords {regular expression}]
[keywords string]
[keywords TeX]
[keywords trimming]
[moddesc   {Text and string utilities, macro processing}]
[titledesc {Procedures to manipulate texts and strings.}]
[category  {Text processing}]
[require Tcl 8.2]
[require textutil [opt 0.8]]
[description]

The package [package textutil] provides commands that manipulate
strings or texts (a.k.a. long strings or string with embedded newlines
or paragraphs).

It is actually a bundle providing the commands of the six packages
Changes to modules/textutil/textutil.tcl.
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
package require textutil::tabify
package require textutil::trim

namespace eval ::textutil {
    # Import the miscellaneous string command for public export

    namespace import -force string::chop string::tail
    namespace import -force string::cap string::uncap
    namespace import -force string::longestCommonPrefix
    namespace import -force string::longestCommonPrefixList

    # Import the repeat commands for public export

    namespace import -force repeat::strRepeat repeat::blank








|







31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
package require textutil::tabify
package require textutil::trim

namespace eval ::textutil {
    # Import the miscellaneous string command for public export

    namespace import -force string::chop string::tail
    namespace import -force string::cap string::uncap string::capEachWord
    namespace import -force string::longestCommonPrefix
    namespace import -force string::longestCommonPrefixList

    # Import the repeat commands for public export

    namespace import -force repeat::strRepeat repeat::blank

59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
    # Import the tabify commands for public export

    namespace import -force tabify::tabify tabify::untabify
    namespace import -force tabify::tabify2 tabify::untabify2

    # Re-export all the imported commands

    namespace export chop tail cap uncap
    namespace export longestCommonPrefix longestCommonPrefixList
    namespace export strRepeat blank
    namespace export adjust indent undent
    namespace export splitx splitn
    namespace export trim trimleft trimright trimPrefix trimEmptyHeading
    namespace export tabify untabify tabify2 untabify2
}


# ### ### ### ######### ######### #########
## Ready

package provide textutil 0.7.1







|












|
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
    # Import the tabify commands for public export

    namespace import -force tabify::tabify tabify::untabify
    namespace import -force tabify::tabify2 tabify::untabify2

    # Re-export all the imported commands

    namespace export chop tail cap uncap capEachWord
    namespace export longestCommonPrefix longestCommonPrefixList
    namespace export strRepeat blank
    namespace export adjust indent undent
    namespace export splitx splitn
    namespace export trim trimleft trimright trimPrefix trimEmptyHeading
    namespace export tabify untabify tabify2 untabify2
}


# ### ### ### ######### ######### #########
## Ready

package provide textutil 0.8
Changes to modules/textutil/textutil.test.
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23

# -------------------------------------------------------------------------

source [file join \
	[file dirname [file dirname [file join [pwd] [info script]]]] \
	devtools testutilities.tcl]

testsNeedTcl     8.2
testsNeedTcltest 1.0

support {
    useLocal     string.tcl   textutil::string
    useLocal     repeat.tcl   textutil::repeat
    useLocal     adjust.tcl   textutil::adjust
    useLocal     split.tcl    textutil::split
    useLocal     tabify.tcl   textutil::tabify







|
|







8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23

# -------------------------------------------------------------------------

source [file join \
	[file dirname [file dirname [file join [pwd] [info script]]]] \
	devtools testutilities.tcl]

testsNeedTcl     8.4
testsNeedTcltest 2.0

support {
    useLocal     string.tcl   textutil::string
    useLocal     repeat.tcl   textutil::repeat
    useLocal     adjust.tcl   textutil::adjust
    useLocal     split.tcl    textutil::split
    useLocal     tabify.tcl   textutil::tabify
131
132
133
134
135
136
137

138



139



140

















141

    textutil::longestCommonPrefixList {foo foo}
} {foo}

test textutil-6.5 {lcs, multiple strings} {
    textutil::longestCommonPrefixList {foo fox fubar}
} {f}




























testsuiteCleanup








>

>
>
>

>
>
>

>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>

>
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
    textutil::longestCommonPrefixList {foo foo}
} {foo}

test textutil-6.5 {lcs, multiple strings} {
    textutil::longestCommonPrefixList {foo fox fubar}
} {f}

# -------------------------------------------------------------------------

test textutil-7.0 {capEachWord, wrong args, not enough} -body {
    textutil::capEachWord
} -returnCodes error -result {wrong # args: should be "textutil::capEachWord sentence"}

test textutil-7.1 {capEachWord, wrong args, too many} -body {
    textutil::capEachWord S X
} -returnCodes error -result {wrong # args: should be "textutil::capEachWord sentence"}

test textutil-7.2 {capEachWord, empty} -body {
    textutil::capEachWord {}
} -result {}

test textutil-7.3 {capEachWord, single word} -body {
    textutil::capEachWord alpha
} -result Alpha

test textutil-7.4 {capEachWord, multiple words} -body {
    textutil::capEachWord {here comes the sun}
} -result {Here Comes The Sun}

test textutil-7.5 {capEachWord, blocks} {
    textutil::capEachWord {here \comes the $sun}
} -result {Here \comes The $sun}

# -------------------------------------------------------------------------
testsuiteCleanup
return
Changes to modules/textutil/textutil_string.man.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23

[manpage_begin textutil::string n 0.7]
[see_also regexp(n)]
[see_also split(n)]
[see_also string(n)]
[keywords capitalize]
[keywords chop]
[keywords {common prefix}]
[keywords formatting]
[keywords prefix]
[keywords string]
[keywords uncapitalize]
[moddesc   {Text and string utilities, macro processing}]
[titledesc {Procedures to manipulate texts and strings.}]
[category  {Text processing}]
[require Tcl 8.2]
[require textutil::string [opt 0.7]]
[description]

The package [package textutil::string] provides miscellaneous string
manipulation commands.

[para]

>
|














|







1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
[vset TU_STRING_VERSION 0.8]
[manpage_begin textutil::string n [vset TU_STRING_VERSION]]
[see_also regexp(n)]
[see_also split(n)]
[see_also string(n)]
[keywords capitalize]
[keywords chop]
[keywords {common prefix}]
[keywords formatting]
[keywords prefix]
[keywords string]
[keywords uncapitalize]
[moddesc   {Text and string utilities, macro processing}]
[titledesc {Procedures to manipulate texts and strings.}]
[category  {Text processing}]
[require Tcl 8.2]
[require textutil::string [opt [vset TU_STRING_VERSION]]]
[description]

The package [package textutil::string] provides miscellaneous string
manipulation commands.

[para]

35
36
37
38
39
40
41






42
43
44
45
46
47
48
A convenience command. Removes the first character of [arg string] and
returns the shortened string.

[call [cmd ::textutil::string::cap] [arg string]]

Capitalizes the first character of [arg string] and returns the
modified string.







[call [cmd ::textutil::string::uncap] [arg string]]

The complementary operation to [cmd ::textutil::string::cap]. Forces
the first character of [arg string] to lower case and returns the
modified string.








>
>
>
>
>
>







36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
A convenience command. Removes the first character of [arg string] and
returns the shortened string.

[call [cmd ::textutil::string::cap] [arg string]]

Capitalizes the first character of [arg string] and returns the
modified string.

[call [cmd ::textutil::string::capEachWord] [arg string]]

Capitalizes the first character of word of the [arg string] and
returns the modified string. Words quoted with either backslash or
dollar-sign are left untouched.

[call [cmd ::textutil::string::uncap] [arg string]]

The complementary operation to [cmd ::textutil::string::cap]. Forces
the first character of [arg string] to lower case and returns the
modified string.