Learn how easy it is to sync an existing GitHub or Google Code repo to a SourceForge project! See Demo

Close

#47 Man page parse(n) 1.4 is in a sad state

open
nobody
None
5
2009-07-01
2009-07-01
Helmut Giese
No

Hello Kevin,
the man page for parse(n) 1.4 is in a sad state.
I suggest the following corrections:

---
Contrary to the description a range is not of the form {first last} but rather {first length}. I suggest the following modifications:

1st paragraph: ... and a range into the script: {first length}. The command parses the script from the first index for <i>length</i> characters. For convenience <i>length</i> can be set to <i>end</i> with the obvious meaning.

Then, change all occurrences of
... [arg first] [arg last]
to
... <i>range</i>

---

2nd paragraph: To the list of tokens add 'expand'

---

3rd paragraph: Change the text to

The <i>first</i> index is treated the same way as are indices in the Tcl string command. An index of 0 refers to the first character of the string. An index of end (or any abbreviation of it) refers to the last character of the string. If first is less than zero then it is treated as if it were zero, and if <i>first + length</i> is greater than or equal to the length of the string then it is treated as if it were end.

if you feel that this description is correct.

---

Remove any mention of 'subcommand' in the Synopsis and in the description. It
does not exist (any more).

---

Under 'Name' at the top of the page please correct this cut 'n paste error
parse - System to control logging of events.

---

'parse list' gives weird results. See below.
I have a work-around - the quickest thing to do is probably to just include the description and code below on the man page.

--- suggested code ---
#
# [parse list] delivers very curious results when $range is surrounded
# by braces (which happens rather often in Tcl) - even if the range
# selects only the text within the braces.
#
# Example:
# set script {{foo bar baz}} ;# braces are part of the script
# parse list $script {1 11} ;# ... but not part of the range
# -> {0 5} {5 3} {9 3} ;# note the '0' - outside of the range (!)
#

You can use the following work-around: Don't hand 'parse list' the original script with the original range, but rather extract the text from the range and pass it to 'parse list' with a range {0 end}. Later adjust the result(s) to point at the correct position in the script.

proc parseList {tree node script range} {
# isolate the source from the original script
set src [parse getstring $script $range]
# let 'parse list' do its work
set res [parse list $src {0 end}]
# adjust the result to point into the original script
set orgStart [lindex $range 0] ;# here our src started in reality
for {set i 0} {$i < [llength $res]} {incr i} {
set start [lindex $res $i 0]
lset res $i 0 [expr {$start + $orgStart}]
}
# process the result
...
}
--- end of suggested code ---

---

Add a description of what the 'countnewline' subcommand does and what parameters it expects.

---

Best regards
Helmut Giese

Discussion