Revision: 69006
          http://sourceforge.net/p/brlcad/code/69006
Author:   starseeker
Date:     2016-10-06 23:53:47 +0000 (Thu, 06 Oct 2016)
Log Message:
-----------
regex based searching wasn't working (looks like it may never have worked 
properly...) - this gets things running, although it needs quite a bit more 
testing.

Modified Paths:
--------------
    brlcad/trunk/src/librt/search.c
    brlcad/trunk/src/librt/search.h

Modified: brlcad/trunk/src/librt/search.c
===================================================================
--- brlcad/trunk/src/librt/search.c     2016-10-06 19:03:34 UTC (rev 69005)
+++ brlcad/trunk/src/librt/search.c     2016-10-06 23:53:47 UTC (rev 69006)
@@ -566,9 +566,16 @@
 HIDDEN int
 f_regex(struct db_plan_t *plan, struct db_node_t *db_node, struct db_i 
*UNUSED(dbip), struct bu_ptbl *UNUSED(results))
 {
+    regex_t reg;
     int ret = 0;
-    ret = !(regexec(&plan->regexp_data, db_path_to_string(db_node->path), 0, 
NULL, 0));
+    if (plan->type == N_IREGEX) {
+       (void)regcomp(&reg, plan->regex_pattern, 
REG_NOSUB|REG_EXTENDED|REG_ICASE);
+    } else {
+       (void)regcomp(&reg, plan->regex_pattern, REG_NOSUB|REG_EXTENDED);
+    }
+    ret = !(regexec(&reg, db_path_to_string(db_node->path), 0, NULL, 0));
     if (!ret) db_node->matched_filters = 0;
+    regfree(&reg);
     return ret;
 }
 
@@ -585,15 +592,16 @@
     } else {
        rv = regcomp(&reg, regexp, REG_NOSUB|REG_EXTENDED);
     }
+    regfree(&reg);
+
     if (rv != 0) {
        bu_log("ERROR: regular expression failed to compile: %s\n", regexp);
        return BRLCAD_ERROR;
     }
 
     newplan = palloc(type, f_regex, tbl);
-    newplan->regexp_data = reg;
+    newplan->regex_pattern = regexp;
     (*resultplan) = newplan;
-    regfree(&reg);
 
     return BRLCAD_OK;
 }

Modified: brlcad/trunk/src/librt/search.h
===================================================================
--- brlcad/trunk/src/librt/search.h     2016-10-06 19:03:34 UTC (rev 69005)
+++ brlcad/trunk/src/librt/search.h     2016-10-06 23:53:47 UTC (rev 69006)
@@ -119,7 +119,7 @@
        char *_depth_data;              /* char pointer */
        char *_node_data;               /* char pointer */
        char *_type_data;
-       regex_t _regex_data;    /* compiled regexp */
+       char *_regex_pattern;           /* regexp pattern */
        int _bool_data;
        int _max_data;                  /* tree depth */
        int _min_data;                  /* tree depth */
@@ -131,7 +131,7 @@
 #define c_data         p_un._c_data
 #define ci_data                p_un._ci_data
 #define path_data      p_un._path_data
-#define regexp_data    p_un._regex_data
+#define regex_pattern  p_un._regex_pattern
 #define attr_data      p_un._attr_data
 #define param_data     p_un._param_data
 #define depth_data     p_un._depth_data

This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.


------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most 
engaging tech sites, SlashDot.org! http://sdm.link/slashdot
_______________________________________________
BRL-CAD Source Commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/brlcad-commits

Reply via email to