Tcl Source Code

View Ticket
Login
Ticket UUID: 1836519
Title: Make two-arg switch safe and fast
Type: Patch Version: None
Submitter: pspjuth Created on: 2007-11-22 15:21:07
Subsystem: 18. Commands M-Z Assigned To: dkf
Priority: 5 Medium Severity:
Status: Closed Last Modified: 2007-12-03 20:47:53
Resolution: Accepted Closed By: dkf
    Closed on: 2007-12-03 13:47:53
Description:
When switch gets two arguments they cannot
legally be options, yet they are scanned
for options leading to that the simple way
of coding:
switch $a {
  xx yy
}
is not as safe as one would hope when $a
happens to begin with "-".

Not parsing for options where they cannot
legally be are common in Tcl commands, e.g.
lsort and lsearch does this.

This patch makes the most straightforward
switch usage also be the safest and fastest.
User Comments: dkf added on 2007-12-03 20:47:53:
Logged In: YES 
user_id=79902
Originator: NO

Implemented, though in a slightly different way.

pspjuth added on 2007-11-22 22:21:08:

File Added - 255442: switch.patch

Attachments: