Skip to content
Tcl Source Code View Ticket
Login

View Ticket

2005-12-02
23:32 • Open ticket [1367506fff]: Inline scan returns too many items plus 4 other ch... artifact: 3d6ab63d0d user: sbron
2005-11-29
07:03 • Ticket [1367506fff]: 6 changes artifact: 65a36d2b58 user: hobbs
07:03 • Pending ticket [1367506fff]. artifact: 5e3990057a user: hobbs
2005-11-27
20:25 • Ticket [1367506fff]: 4 changes artifact: 72d39094b9 user: sbron
20:25 • Add attachment scan.patch to ticket [1367506fff] artifact: 126923a217 user: sbron
20:25 • Ticket [1367506fff] Inline scan returns too many items status still Open wit... artifact: 842e9f06b9 user: sbron
13:08 • New ticket [1367506fff]. artifact: d9531362af user: sbron

Inline scan returns too many items

Open1367506fffffffffffffffffffffffffffffffffCreated 21 years agoUpdated 21 years ago
Descriptionplain2005-11-27 13:08:33
Doing: [scan 0.99 %d.%d.%d.%d a b c d] returns 2 and
only variables a and b are set. Variable c and d are
not being touched. If these variables did not exist
before, they still don't exist after the operation.
Otherwise they will still have their old value.

According to the manual page: "If no varName variables
are specified, then scan works in an inline manner,
returning the data that would otherwise be stored in
the variables as a list".

From this information I expect [scan 0.99 %d.%d.%d.%d]
to return a list with two elements. However, the
command returns a list with four elements: 0 99 {} {}
sbron Ticket [1367506fff]: 1 change [History diff]2005-11-27 20:25:08
sbronplain2005-11-27 20:25:10
File Added - 157677: scan.patch
hobbs Pending ticket [1367506fff]. [History diff]2005-11-29 07:03:48
hobbsplain2005-11-29 07:03:49
Logged In: YES 
user_id=72656

Note that the next sentence is "In the inline case, an empty
string is returned when the end of the input string is
reached before any conversions have been performed.", and
perhaps that needs augmenting to say that each %-sub that
goes unmatched also makes an empty string.  Inline scan does
intentionally operate to return a list equal in length to
the number of %-subs.
sbronplain2005-12-02 23:32:14
Logged In: YES 
user_id=37987

That next line refers to the fact that [scan "" %d.%d.%d.%d]
returns an empty string and not a list of four empty
strings. That is actually consistent with the expected
result I described.

The only situation that is inconsistent is a partial match.
I have seen the code and noticed that it intentionally adds
empty list entries. But that doesn't automatically make it
the right thing to do.

I do realize that this is unlikely to be changed because
that might break existing code that accounts for the current
behavior. So probably the only thing that can be done now is
to warn people about this illogical behavior in the manual page.
Log in (anonymous is fine) to add a comment.

Attachments: