]> granicus.if.org Git - graphviz/commitdiff
remove use of regex in smyrna
authorMatthew Fernandez <matthew.fernandez@gmail.com>
Sun, 14 Feb 2021 18:40:12 +0000 (10:40 -0800)
committerMatthew Fernandez <matthew.fernandez@gmail.com>
Sat, 20 Feb 2021 23:51:09 +0000 (15:51 -0800)
This "regex" was only ever used to match literals like "R" and the empty string.
Related to #1919.

cmd/smyrna/btree.c

index c665daaaab51c7020f5bc9a7d6a957eaf65a6820..604e275eb71718dcc98c789b63bd833b552a0ae5 100644 (file)
  *************************************************************************/
 
 #include "btree.h"
-#ifdef _WIN32
-#include <regex_win32.h>
-#else
-#include <regex.h>
-#endif
 
 #include <common/memory.h>
+#include <string.h>
 
 btree_node *new_node(char *attribute, char *regex, float min, float max)
 {
@@ -310,7 +306,6 @@ int evaluate_filter_atom(char *string, btree_node * Nodes[], char *op)
 
 int evaluate_expresions(tv_node * TV_Node, btree_node * n)
 {
-    regex_t preg;
     char *data;
     int i = 0;
     int ii = 0;
@@ -335,12 +330,10 @@ int evaluate_expresions(tv_node * TV_Node, btree_node * n)
            agget(view->Topview->Nodes[TV_Node->index].Node, n->attr_name);
 //fprintf(stderr,"  = %s\n", data);
        if (data) {
-           regcomp(&preg, n->regex, REG_NOSUB);
-           if (regexec(&preg, data, 0, 0, 0) == 0)
+           if (strstr(data, n->regex) != NULL)
                n->value = 1;
            else
                n->value = 0;
-           regfree(&preg);
        } else
            n->value = 1;       //no attribute return 1
     } else