[137549] branches/gsoc15-dependency/base/src/macports1.0/macports_libsolv. tcl

ijackson at macports.org ijackson at macports.org
Sun Jun 14 03:47:34 PDT 2015


Revision: 137549
          https://trac.macports.org/changeset/137549
Author:   ijackson at macports.org
Date:     2015-06-14 03:47:34 -0700 (Sun, 14 Jun 2015)
Log Message:
-----------
Add support for search options in libsolv search engine.
Now libsolv search support options passed to search
i.e. --exact, --glob, --regex, --case-sensitive.
First check for $matchstyle inside switch and set the flag to
value corresponding to the option. Then check for case_sensitive,
If case-sensitive is not passed then Binary OR with the
initialized flag. We do not keep a if{$case_sensitive} block in each
switch case like the builtin engine as the flag value in libsolv
can be Binary OR'ed.

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-14 08:09:38 UTC (rev 137548)
+++ branches/gsoc15-dependency/base/src/macports1.0/macports_libsolv.tcl	2015-06-14 10:47:34 UTC (rev 137549)
@@ -101,15 +101,37 @@
 
     ## Search using libsolv. Needs some more work.
     #  To Do list:
+    #  Return portinfo to mportsearch which will pass the info to port.tcl to print results.
+    #  Done:
     #  Add support for search options i.e. --exact, --case-sensitive, --glob, --regex.
-    #  Return portinfo to mportsearch which will pass the info to port.tcl to print results.
     proc search {pattern {case_sensitive yes} {matchstyle regexp}  } {
         variable pool
 
         set sel [$pool Selection]
-        set di [$pool Dataiterator $solv::SOLVABLE_NAME $pattern \
-        [expr $solv::Dataiterator_SEARCH_GLOB | $solv::Dataiterator_SEARCH_NOCASE]]
+       
+        ## Initialize search option flag depending on the option passed to port search
+        switch -- $matchstyle {
+            exact {
+                set di_flag [expr $solv::Dataiterator_SEARCH_STRING]
+            }
+            glob {
+                set di_flag [expr $solv::Dataiterator_SEARCH_GLOB]
+            }
+            regexp {
+                set di_flag [expr $solv::Dataiterator_SEARCH_REGEX]
+            }
+            default {
+                return -code error "mportsearch: Unsupported matching style: ${matchstyle}."
+            }
+        }
 
+        ## If --case-sensitive is not passed, Binary OR "|" with no_case flag.
+        if {!${case_sensitive}} {
+            set di_flag [expr $di_flag | $solv::Dataiterator_SEARCH_NOCASE]
+        }
+        
+        set di [$pool Dataiterator $solv::SOLVABLE_NAME $pattern $di_flag]
+
         while {[set data [$di __next__]] ne "NULL"} { 
             $sel add_raw $solv::Job_SOLVER_SOLVABLE [$data cget -solvid]
         }
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.macosforge.org/pipermail/macports-changes/attachments/20150614/8c7da607/attachment.html>


More information about the macports-changes mailing list