--- dfa.c.1.36	2005-08-07 21:21:27.000000000 +0200
+++ dfa.c	2005-08-07 21:07:15.000000000 +0200
@@ -170,9 +170,7 @@ static char *istrstr PARAMS ((char *look
 static void ifree PARAMS ((char *cp));
 static void freelist PARAMS ((char **cpp));
 static char **enlist PARAMS ((char **cpp, char *new, size_t len));
-static char **comsubs PARAMS ((char *left, char *right));
 static char **addlists PARAMS ((char **old, char **new));
-static char **inboth PARAMS ((char **left, char **right));
 
 static ptr_t
 xcalloc (size_t n, size_t s)
@@ -3145,11 +3143,11 @@ dfafree (struct dfa *d)
 		p->is##q->left	p->right##q->is	p->is##q->is :	p->right##q->left
 						ZERO
 
-	OR	longest common	longest common	(do p->is and	substrings common to
-		leading		trailing	q->is have same	p->in and q->in
-		(sub)sequence	(sub)sequence	length and
-		of p->left	of p->right	content) ?
-		and q->left	and q->right	p->is : NULL
+	OR	longest common	longest common	(do p->is and	p->in != ZERO &&
+		leading		trailing	q->is have same	q->in != ZERO ?
+		(sub)sequence	(sub)sequence	length and      p->in plus
+		of p->left	of p->right	content) ?      q->in 
+		and q->left	and q->right	p->is : NULL    : NULL
 
    If there's anything else we recognize in the tree, all four sequences get set
    to zero-length sequences.  If there's something we don't recognize in the tree,
@@ -3284,42 +3282,6 @@ enlist (char **cpp, char *new, size_t le
   return cpp;
 }
 
-/* Given pointers to two strings, return a pointer to an allocated
-   list of their distinct common substrings. Return NULL if something
-   seems wild. */
-static char **
-comsubs (char *left, char *right)
-{
-  char **cpp;
-  char *lcp;
-  char *rcp;
-  size_t i, len;
-
-  if (left == NULL || right == NULL)
-    return NULL;
-  cpp = (char **) malloc(sizeof *cpp);
-  if (cpp == NULL)
-    return NULL;
-  cpp[0] = NULL;
-  for (lcp = left; *lcp != '\0'; ++lcp)
-    {
-      len = 0;
-      rcp = strchr (right, *lcp);
-      while (rcp != NULL)
-	{
-	  for (i = 1; lcp[i] != '\0' && lcp[i] == rcp[i]; ++i)
-	    continue;
-	  if (i > len)
-	    len = i;
-	  rcp = strchr (rcp + 1, *lcp);
-	}
-      if (len == 0)
-	continue;
-      if ((cpp = enlist(cpp, lcp, len)) == NULL)
-	break;
-    }
-  return cpp;
-}
 
 static char **
 addlists (char **old, char **new)
@@ -3337,40 +3299,6 @@ addlists (char **old, char **new)
   return old;
 }
 
-/* Given two lists of substrings, return a new list giving substrings
-   common to both. */
-static char **
-inboth (char **left, char **right)
-{
-  char **both;
-  char **temp;
-  int lnum, rnum;
-
-  if (left == NULL || right == NULL)
-    return NULL;
-  both = (char **) malloc(sizeof *both);
-  if (both == NULL)
-    return NULL;
-  both[0] = NULL;
-  for (lnum = 0; left[lnum] != NULL; ++lnum)
-    {
-      for (rnum = 0; right[rnum] != NULL; ++rnum)
-	{
-	  temp = comsubs(left[lnum], right[rnum]);
-	  if (temp == NULL)
-	    {
-	      freelist(both);
-	      return NULL;
-	    }
-	  both = addlists(both, temp);
-	  freelist(temp);
-	  free(temp);
-	  if (both == NULL)
-	    return NULL;
-	}
-    }
-  return both;
-}
 
 typedef struct
 {
@@ -3486,12 +3414,15 @@ dfamust (struct dfa *dfa)
 	    for (j = 0; j < i; ++j)
 	      lmp->right[j] = lmp->right[(ln - i) + j];
 	    lmp->right[j] = '\0';
-	    new = inboth(lmp->in, rmp->in);
-	    if (new == NULL)
-	      goto done;
-	    freelist(lmp->in);
-	    free((char *) lmp->in);
-	    lmp->in = new;
+	    /* In.  Everything in left, plus everything in right */
+            if (lmp->in[0] != NULL && rmp->in[0] != NULL) 
+               {
+	       lmp->in = addlists(lmp->in, rmp->in);
+	       if (lmp->in == NULL)
+	          goto done;
+               } 
+            else
+	       freelist(lmp->in);
 	  }
 	  break;
 	case PLUS:
@@ -3614,12 +3545,15 @@ dfamust (struct dfa *dfa)
  done:
   if (strlen(result))
     {
-      MALLOC(dm, struct dfamust, 1);
-      dm->exact = exact;
-      MALLOC(dm->must, char, strlen(result) + 1);
-      strcpy(dm->must, result);
-      dm->next = dfa->musts;
-      dfa->musts = dm;
+      for (i = 0; musts[0].in[i]; ++i) 
+        {
+          MALLOC(dm, struct dfamust, 1);
+          dm->exact = strcmp(result,musts[0].in[i])? 0 : exact; 
+          MALLOC(dm->must, char, strlen(musts[0].in[i]) + 1);
+          strcpy(dm->must, musts[0].in[i]);
+          dm->next = dfa->musts;
+          dfa->musts = dm;
+        }
     }
   mp = musts;
   for (i = 0; i <= dfa->tindex; ++i)
