- Added coloring option to graph saving.
[oweals/gnunet.git] / src / regex / regex.c
index 2152167dc3944e57bb44bd7f9e97326fd4e584bd..c8b8ad3faedb680268ff3256c91ea8b868a9a449 100644 (file)
@@ -766,7 +766,8 @@ number_states (void *cls, unsigned int count, struct GNUNET_REGEX_State *s)
   struct GNUNET_REGEX_State **states = cls;
 
   s->proof_id = count;
-  states[count] = s;
+  if (NULL != states)
+    states[count] = s;
 }
 
 
@@ -1914,7 +1915,7 @@ nfa_add_question_op (struct GNUNET_REGEX_Context *ctx)
   struct GNUNET_REGEX_State *end;
 
   a = ctx->stack_tail;
-  
+
   if (NULL == a)
   {
     GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
@@ -2174,6 +2175,9 @@ GNUNET_REGEX_construct_nfa (const char *regex, const size_t len)
 
   nfa->regex = GNUNET_strdup (regex);
 
+  /* create depth-first numbering of the states for pretty printing */
+  GNUNET_REGEX_automaton_traverse (nfa, &number_states, NULL);
+
   return nfa;
 
 error: