gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[GNUnet-SVN] r23428 - gnunet/src/regex


From: gnunet
Subject: [GNUnet-SVN] r23428 - gnunet/src/regex
Date: Mon, 27 Aug 2012 11:58:39 +0200

Author: szengel
Date: 2012-08-27 11:58:39 +0200 (Mon, 27 Aug 2012)
New Revision: 23428

Modified:
   gnunet/src/regex/regex.c
   gnunet/src/regex/regex_internal.h
Log:
Fixes


Modified: gnunet/src/regex/regex.c
===================================================================
--- gnunet/src/regex/regex.c    2012-08-27 09:24:21 UTC (rev 23427)
+++ gnunet/src/regex/regex.c    2012-08-27 09:58:39 UTC (rev 23428)
@@ -36,34 +36,6 @@
 
 
 /**
- * Context that contains an id counter for states and transitions as well as a
- * DLL of automatons used as a stack for NFA construction.
- */
-struct GNUNET_REGEX_Context
-{
-  /**
-   * Unique state id.
-   */
-  unsigned int state_id;
-
-  /**
-   * Unique transition id.
-   */
-  unsigned int transition_id;
-
-  /**
-   * DLL of GNUNET_REGEX_Automaton's used as a stack.
-   */
-  struct GNUNET_REGEX_Automaton *stack_head;
-
-  /**
-   * DLL of GNUNET_REGEX_Automaton's used as a stack.
-   */
-  struct GNUNET_REGEX_Automaton *stack_tail;
-};
-
-
-/**
  * Set of states.
  */
 struct GNUNET_REGEX_StateSet
@@ -770,9 +742,14 @@
   struct GNUNET_REGEX_Transition *t;
   struct GNUNET_REGEX_Transition *t_next;
 
+  if (1 > stride_len)
+    return;
+
+  // Compute the new transitions.
   GNUNET_REGEX_automaton_traverse (dfa, dfa->start, NULL, NULL,
                                    &add_multi_strides_to_dfa, &ctx);
 
+  // Add all the new transitions to the automaton.
   for (t = ctx.transitions_head; NULL != t; t = t_next)
   {
     t_next = t->next;
@@ -2700,6 +2677,31 @@
 
 
 /**
+ * Get the number of transitions that are contained in the given automaton.
+ *
+ * @param a automaton for which the number of transitions should be returned.
+ *
+ * @return number of transitions in the given automaton.
+ */
+unsigned int
+GNUNET_REGEX_get_transition_count (struct GNUNET_REGEX_Automaton *a)
+{
+  unsigned int t_count;
+  struct GNUNET_REGEX_State *s;
+
+  if (NULL == a)
+    return 0;
+
+  for (t_count = 0, s = a->states_head; NULL != s; s = s->next)
+  {
+    t_count += s->transition_count;
+  }
+
+  return t_count;
+}
+
+
+/**
  * Get the first key for the given 'input_string'. This hashes the first x bits
  * of the 'input_string'.
  *

Modified: gnunet/src/regex/regex_internal.h
===================================================================
--- gnunet/src/regex/regex_internal.h   2012-08-27 09:24:21 UTC (rev 23427)
+++ gnunet/src/regex/regex_internal.h   2012-08-27 09:58:39 UTC (rev 23428)
@@ -315,13 +315,65 @@
  *
  * @param a automaton for which the canonical regex should be returned.
  *
- * @return
+ * @return canonical regex string.
  */
 const char *
 GNUNET_REGEX_get_canonical_regex (struct GNUNET_REGEX_Automaton *a);
 
 
 /**
+ * Get the number of transitions that are contained in the given automaton.
+ *
+ * @param a automaton for which the number of transitions should be returned.
+ *
+ * @return number of transitions in the given automaton.
+ */
+unsigned int
+GNUNET_REGEX_get_transition_count (struct GNUNET_REGEX_Automaton *a);
+
+
+/**
+ * Context that contains an id counter for states and transitions as well as a
+ * DLL of automatons used as a stack for NFA construction.
+ */
+struct GNUNET_REGEX_Context
+{
+  /**
+   * Unique state id.
+   */
+  unsigned int state_id;
+
+  /**
+   * Unique transition id.
+   */
+  unsigned int transition_id;
+
+  /**
+   * DLL of GNUNET_REGEX_Automaton's used as a stack.
+   */
+  struct GNUNET_REGEX_Automaton *stack_head;
+
+  /**
+   * DLL of GNUNET_REGEX_Automaton's used as a stack.
+   */
+  struct GNUNET_REGEX_Automaton *stack_tail;
+};
+
+
+/**
+ * Adds multi-strided transitions to the given 'dfa'.
+ *
+ * @param regex_ctx regex context needed to add transitions to the automaton.
+ * @param dfa DFA to which the multi strided transitions should be added.
+ * @param stride_len length of the strides.
+ */
+void
+GNUNET_REGEX_add_multi_strides_to_dfa (struct GNUNET_REGEX_Context *regex_ctx,
+                                       struct GNUNET_REGEX_Automaton *dfa,
+                                       const unsigned int stride_len);
+
+
+/**
  * Generate a (pseudo) random regular expression of length 'rx_length', as well
  * as a (optional) string that will be matched by the generated regex. The
  * returned regex needs to be freed.




reply via email to

[Prev in Thread] Current Thread [Next in Thread]