[137804] branches/gsoc15-dependency/base/src/macports1.0/macports_libsolv. tcl
ijackson at macports.org
ijackson at macports.org
Sat Jun 20 05:09:15 PDT 2015
Revision: 137804
https://trac.macports.org/changeset/137804
Author: ijackson at macports.org
Date: 2015-06-20 05:09:15 -0700 (Sat, 20 Jun 2015)
Log Message:
-----------
Replace if-elseif block with switch block
Replace if-elseif block with switch block. It helps
in handling unknown options and enables easy addition
of options in future. Remove unnecessary [expr ].
Modified Paths:
--------------
branches/gsoc15-dependency/base/src/macports1.0/macports_libsolv.tcl
Modified: branches/gsoc15-dependency/base/src/macports1.0/macports_libsolv.tcl
===================================================================
--- branches/gsoc15-dependency/base/src/macports1.0/macports_libsolv.tcl 2015-06-20 11:46:11 UTC (rev 137803)
+++ branches/gsoc15-dependency/base/src/macports1.0/macports_libsolv.tcl 2015-06-20 12:09:15 UTC (rev 137804)
@@ -164,16 +164,16 @@
## Initialize search option flag depending on the option passed to port search
switch -- $matchstyle {
exact {
- set di_flag [expr $solv::Dataiterator_SEARCH_STRING]
+ set di_flag $solv::Dataiterator_SEARCH_STRING
}
glob {
- set di_flag [expr $solv::Dataiterator_SEARCH_GLOB]
+ set di_flag $solv::Dataiterator_SEARCH_GLOB
}
regexp {
- set di_flag [expr $solv::Dataiterator_SEARCH_REGEX]
+ set di_flag $solv::Dataiterator_SEARCH_REGEX
}
default {
- return -code error "mportsearch: Unsupported matching style: ${matchstyle}."
+ return -code error "Libsolv search: Unsupported matching style: ${matchstyle}."
}
}
@@ -183,16 +183,28 @@
}
## Set options for search. Binary OR the $search_option to lookup more fields.
- if {$field eq "name"} {
- set search_option $solv::SOLVABLE_NAME
- } elseif {$field eq "description"} {
- set search_option $solv::SOLVABLE_SUMMARY
- } elseif {$field eq "long_description"} {
- set search_option $solv::SOLVABLE_DESCRIPTION
- } elseif {$field eq "homepage"} {
- set search_option $solv::SOLVABLE_URL
- } elseif {$field eq "categories"} {
- set search_option $solv::SOLVABLE_CATEGORY
+ switch -- $field {
+ name {
+ set search_option $solv::SOLVABLE_NAME
+ }
+ description {
+ set search_option $solv::SOLVABLE_SUMMARY
+ }
+ long_description {
+ set search_option $solv::SOLVABLE_DESCRIPTION
+ }
+ homepage {
+ set search_option $solv::SOLVABLE_URL
+ }
+ categories {
+ set search_option $solv::SOLVABLE_CATEGORY
+ }
+ ## $field is yes in alternate iteration i.e. description, yes, name, yes and so on.
+ yes {
+ }
+ default {
+ return -code error "Libsolv search: Unsupported field: ${field}."
+ }
}
set di [$pool Dataiterator $search_option $pattern $di_flag]
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.macosforge.org/pipermail/macports-changes/attachments/20150620/cd621cdc/attachment-0001.html>
More information about the macports-changes
mailing list