Ticket #53089: patch-options-contains.diff

File patch-options-contains.diff, 1.4 KB (added by RJVB (René Bertin), 7 years ago)
  • src/port1.0/portutil.tcl

    diff --git src/port1.0/portutil.tcl src/port1.0/portutil.tcl
    index 1370678..7881715 100644
    proc handle_option {option args} { 
    9797}
    9898
    9999##
     100# Handle option-contains
     101#
     102# @param option name of the option
     103# @param args arguments, can contain one of lsearch's options
     104proc handle_option-contains {option args} {
     105    global $option user_options option_procs
     106
     107    if {![info exists user_options($option)] && [info exists $option]} {
     108        set arg0 [lindex $args 0]
     109        if {[string index $arg0 0] eq "-"} {
     110            set searchopt $arg0
     111            set args [lrange $args 1 end]
     112        } else {
     113            set searchopt "-exact"
     114        }
     115        if {[lsearch $searchopt [set $option] $args] >= 0} {
     116            return yes
     117        }
     118    }
     119    return no
     120}
     121
     122##
    100123# Handle option-append
    101124#
    102125# @param option name of the option
    proc handle_option-replace {option args} { 
    204220proc options {args} {
    205221    foreach option $args {
    206222        interp alias {} $option {} handle_option $option
     223        interp alias {} $option-contains {} handle_option-contains $option
    207224        interp alias {} $option-append {} handle_option-append $option
    208225        interp alias {} $option-prepend {} handle_option-prepend $option
    209226        interp alias {} $option-delete {} handle_option-delete $option